Foxify Configuration
In case of using GitHub package registry, the package name will be
@foxifyjs/config.
npm i @foxify/configpnpm add @foxify/configyarn add @foxify/configCreate the foxify.config.js file at the root of your project. (Optional)
In case of the config file missing, the default values will be used.
| Config | Type | Default | Description |
|---|---|---|---|
env | production, development, test | process.env.NODE_ENV or development | Node.js environment. |
xPoweredBy | Boolean | true | Indicates whether the X-Powered-By header should be present or not. |
workers | Integer between 1 and number of cpu cores | 1 | Number of Node.js cluster workers to be created. In case of 1 Node.js cluster workers won't be used. |
etag | (body: string / Buffer, encoding?: BufferEncoding) => string | - | ETag response header value generator. |
server | Object | - | Server config. |
server.protocol | http, https | http | Server protocol. |
server.hostname | String | localhost | Server hostname. |
server.port | Integer between 0 and 65535 | 3000 | Server port. |
subdomain | Object | - | Subdomain config. |
subdomain.offset | Non-negative integer | 2 | The number of dot-separated parts of the host to remove to access subdomain. |
json | Object | - | JSON config. |
json.escape | Boolean | false | Enable escaping JSON responses from the res.json, res.jsonp, and res.send APIs. |
json.replacer | (key: string, value: unknown) => unknown | - | The replacer argument used by JSON.stringify. |
json.spaces | Non-negative integer | 0 | The space argument used by JSON.stringify. This is typically set to the number of spaces to use to indent prettified JSON. |
jsonp | Object | - | JSONP config. |
jsonp.callback | String | callback | The JSONP callback name. |
query | Object | - | Request query string config. |
query.parser | (queryString: string) => Record<string, any> | qs.parse | A custom query string parsing function will receive the complete query string, and must return an object of query keys and their values. |
proxy | Object | - | Proxy config. |
proxy.trust | (ip: string, hopIndex: number) => boolean | () => false | Indicates whether the app is behind a front-facing proxy, and to use the X-Forwarded-* headers to determine the connection and the IP address of the client. |
The exported config values are frozen using
Object.freeze.
Config file contents (foxify.config.js):
exportdefault{env: "development",xPoweredBy: true,workers: 1,server: {protocol: "http",hostname: "localhost",port: 3000,},subdomain: {offset: 2,},json: {escape: false,spaces: 0,},jsonp: {callback: "callback",},query: {parser: qs.parse,},proxy: {trust: ()=>false,},};Consume the config values:
importconfigfrom"@foxify/config";Config file contents (foxify.config.js):
module.exports={env: "development",xPoweredBy: true,workers: 1,server: {protocol: "http",hostname: "localhost",port: 3000,},subdomain: {offset: 2,},json: {escape: false,spaces: 0,},jsonp: {callback: "callback",},query: {parser: qs.parse,},proxy: {trust: ()=>false,},};Consume the config values:
constconfig=require("@foxify/config").default;We use SemVer for versioning. For the versions available, see the releases on this repository.
- Ardalan Amini - Core Maintainer - @ardalanamini
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details