Setup simple SSR, untested
This commit is contained in:
parent
949b008208
commit
360dc83ded
3
packages/client/src/csrf/CsrfTokenReducer.ts
Normal file
3
packages/client/src/csrf/CsrfTokenReducer.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function CsrfToken(state = '') {
|
||||
return state
|
||||
}
|
||||
1
packages/client/src/csrf/index.ts
Normal file
1
packages/client/src/csrf/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './CsrfTokenReducer'
|
||||
@ -1,5 +1,6 @@
|
||||
export * from './actions'
|
||||
export * from './components'
|
||||
export * from './csrf'
|
||||
export * from './http'
|
||||
export * from './login'
|
||||
export * from './middleware'
|
||||
|
||||
@ -2,17 +2,14 @@ import {PromiseMiddleware} from '../middleware'
|
||||
import {
|
||||
applyMiddleware,
|
||||
createStore as create,
|
||||
combineReducers,
|
||||
Middleware,
|
||||
Action,
|
||||
// AnyAction,
|
||||
DeepPartial,
|
||||
ReducersMapObject,
|
||||
// Reducer,
|
||||
Reducer,
|
||||
} from 'redux'
|
||||
|
||||
export interface ICreateStoreParams<State, A extends Action> {
|
||||
reducers: ReducersMapObject<State, A | any>
|
||||
reducer: Reducer<State, A>
|
||||
state?: DeepPartial<State>
|
||||
middleware?: Middleware[]
|
||||
}
|
||||
@ -25,7 +22,7 @@ export function createStore<State, A extends Action>(
|
||||
) {
|
||||
const middleware = params.middleware || [new PromiseMiddleware().handle]
|
||||
return (state?: DeepPartial<State>) => create(
|
||||
combineReducers(params.reducers),
|
||||
params.reducer,
|
||||
state,
|
||||
applyMiddleware(...middleware),
|
||||
)
|
||||
|
||||
@ -47,7 +47,7 @@ export class TestUtils {
|
||||
params: IRenderParams<State>,
|
||||
) {
|
||||
const store = this.createStore({
|
||||
reducers: params.reducers,
|
||||
reducer: this.combineReducers(params.reducers),
|
||||
})(params.state)
|
||||
const Component = params.connector.connect(params.select)
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ export class Application implements IApplication {
|
||||
this.configureMiddleware(router)
|
||||
this.configureRouter(router)
|
||||
this.configureApiErrorHandling(router)
|
||||
this.configureFrontend(router)
|
||||
|
||||
server.use(this.config.app.context, router)
|
||||
this.configureGlobalErrorHandling(server)
|
||||
@ -78,6 +79,7 @@ export class Application implements IApplication {
|
||||
}
|
||||
|
||||
protected configureRouter(router: express.Router) {
|
||||
// TODO use /api for LoginRoutes
|
||||
router.use('/app', new routes.LoginRoutes(
|
||||
this.userService,
|
||||
this.authenticator,
|
||||
@ -104,6 +106,10 @@ export class Application implements IApplication {
|
||||
router.use('/api', new middleware.ErrorApiHandler(apiLogger).handle)
|
||||
}
|
||||
|
||||
protected configureFrontend(router: express.Router) {
|
||||
// Override this method
|
||||
}
|
||||
|
||||
protected configureGlobalErrorHandling(server: express.Application) {
|
||||
const apiLogger = this.getApiLogger()
|
||||
server.use(new middleware.ErrorPageHandler(apiLogger).handle)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user