config/config.js
file.Name Config | Description |
---|---|
env_path: string |
The path to the environment configuration file (.env ).When you start the Express Sweet application, the contents of the environment configuration file are automatically read and saved in process.env .The default is .env .
|
cors_enabled: boolean |
Set to true to allow requests from another domain to the application. The default is false . |
max_body_size: string|number |
Controls the maximum request body size. If this is a number, then the value specifies the number of bytes. if it is a string, the value is passed to the bytes library for parsing. The default is 100kb. |
router_dir: string |
The directory path where the routes module is located. The default is the routes directory directly under the application root. |
default_router: string |
Express Sweet can be told to load a default router when a URI is not present, as will be the case when root URL (/ ) is requested.For example, to specify a default route, set default_router as follows.Where blog is the name of the router module you want used. Next, create the routes/blog.js module.In the following example, requesting the root URL ( / ) will result in "Hello World".
|
rewrite_base_url: (baseUrl: string) => string |
This is a hook that rewrites the base URL. If you want to rewrite the app.locals.baseUrl property and the view's baseUrl variable, use this hook to return a new base URL. The default value is the referrer's origin (eg https://example.com). In this example, https://example.com/admin is used as the base URL.
|
is_ajax: (req: express.Request) => boolean |
How to determine if it is an ajax request. The default is that if there is an XMLHttpRequest in the request header ( req.xhr ) returns true .For example, if there is no XMLHttpRequest in req( express.Request ) and the Ajax endpoint starts with /api , a custom Ajax decision can be made like "return /^\/api\//.test(req.path) ".
|
hook_handle_error: (err: any, req: express.Request, res: express.Response, next: express.NextFunction) => void |
Hooks the default behavior on request errors. If unset, simply returns an error HTTP status. ( res.status(err.status||500).end(); )
|