Custom Server App
Custom server app can be defined by user through src/_server/index.js
filesystem hooks. We provided a initServer
wrapper function that could be imported from @treats/server
.
// src/_server/index.js
import initServer from "@treats/server";
const app = initServer();
export default app;
With custom server app we could register server addons like helpers, middlewares or events etc.
Customizing server app
To customize server app, we could supply a configuration object to initServer
wrapper function:
customMiddlewares
- To register custom middlewares. See more on middleware section.customHelpers
- To register custom helpers. See more on helper section.customEvents
- To register custom events. See more on server-side event section.
// src/_server/index.js
import initServer from "@treats/server";
import { customMiddlewareA, customMiddlewareB } from "@treats/addons-example";
const app = initServer({
customMiddlewares: [customMiddlewareA, customMiddlewareB]
});
export default app;