Skip to content

Configuration

FexAPI configuration is loaded from fexapi.config.js in your project root.

CLI flags override file values at runtime.

Config File

js
module.exports = {
  port: 4000,
  cors: true,
  delay: 200,
  routes: {
    "/users": { count: 20, schema: "user" },
  },
};

Options Reference

OptionTypeDefaultDescription
portnumber4000Server port. CLI --port overrides this.
corsbooleanfalseEnable CORS headers and OPTIONS preflight.
delaynumber0Response delay in milliseconds.
routesobject{}Optional route-level overrides.

Routes Config

The routes object maps endpoint paths to their configuration:

js
routes: {
  "/users": {
    count: 50,
    schema: "user"
  }
}
PropertyTypeDescription
countnumberNumber of records to return (1-50)
schemastringSchema name that resolves to fexapi/schemas/<name>.yaml

If the schema name doesn't match any file in fexapi/schemas/, FexAPI falls back to a generic record structure.

Schema File vs Config Routes

FexAPI supports two ways to define routes:

schema.fexapifexapi.config.js routes
FormatDSLJavaScript
Best forPrimary API contractCount/schema overrides
Data sourceGenerated API specRuntime route config

Both can be used together. If the same path appears in both, schema-generated routes take precedence.

Port and Route Precedence

CLI flags → fexapi.config.js port → generated schema port → 4000

For route precedence, schema-generated routes also win when the same path exists in both places.

Next Steps

Released under the MIT License.