Configuration
One of the most important philosophies of Claypot is declarative programming. You can create a powerful server by defining a configuration file.
The configuration file must export a JSON object.
Claypotfile
By default, claypot will find up the closest Claypotfile.js as configuration from the root of project.
You can use a custom file name by adding --configFile option to claypot start command. The --configFile value is the configuration file name for resolving.
Properties
Note: all properties are optional.
baseDir(String): Defining the base directory for resolving modules or directories. Defaults tocwd.clayInjection(Boolean): Injectclayobject to middleware context. Defaults totrue.compress(Boolean|Object): Compress (gzip) static files. Defaults totrueinproductionmode,falseindevelopmentmode. Please Note thattruewill use compressible to decide to compress.configs(Any): Custom data is recommended to set to here.cwd(String): Defining the current working directory. Defaults toprocess.cwd(). Not available instartPuremethod.daemon(Boolean): Enabledaemonmode. Notice: to killdaemonprocess, please runclaypot stop ${name}. Defaults tofalse. Not available instartPuremethod.dbs(Object): Defining databases. There's no built-in database by default. You probably need to use some plugins if you to use some databases.env(Object): Defining custom environments. Defaults toprocess.env. Not available instartPuremethod.execArgs(String|[String]): Executing arguments. Defaults to[]. Not available instartPuremethod.execCommand(String): Executing command. Defaults toprocess.execPath, which returns the absolute pathname of the executable that started the Node.js process i.e./usr/local/bin/node. Not available instartPuremethod.favicon(Boolean|String): Defining favicon. Settingfalseto disable this feature. Setting a path string to set a custom favicon file. Defaults totrue.helmet(Boolean|Object): Enable helmet for safety. Defaults totrueinproductionmode,falseindevelopmentmode.historyAPIFallback(Boolean|Object): Enable history api fallback. Useful for SPA. Defaults tofalse.host(String): Server host.httpError(Boolean|Object): Enable server error handling. Setting a object for custom config. Defaults totrue.httpLogger(Boolean): Enable HTTP access logger. Defaults totrue.inspect(Boolean|String|Object): Enable node inspector. Defaults tofalse. Not available instartPuremethod.logLevel(String|Object): Defining log level. See pot-logger for detail. Here are available levels:- ALL
- TRACE
- DEBUG (default in
developmentmode) - INFO (default in
productionmode) - WARN
- ERROR
- FATAL
- OFF
logsDir(String): Defining log files directory. Ifdaemonmode actived, log messages will write to some.logfiles. Defaults to".logs".maxRestarts(Number): Defining max restarts if crashed. Defaults to-1(-1equals toInfinity) inproductionmode,0indevelopmentmode. Not available instartPuremethod.models(String): Defining models files directory. Defaults to"models".name(String): Defining server name. Defaults to the basename ofprocess.cwd().notFound(Boolean): Enable 404 handling. Defaults totrue.outputHost(Boolean|Object): Output host info for development. Please checkout output-host for detail. Defaults totrueindevelopmentmode. Not available instartPuremethod.overrideConsole(Boolean): Enable overriding nativeconsole. Defaults tofalse.plugins([Object]): Defining plugins.port(Number): Defining the port of server. Defaults to an available port.production(Boolean): Enableproductionmode. Defaults totrue.proxy(Object): Defining HTTP proxies. e.g.{ '/my/path/': 'http://anti.proxy.com/' }. See HTTP Proxy for detail.responseTime(Boolean): Enablex-response-timeto HTTP response header. Defaults totrue.rewrites(Object): URL Rewrite by setting a key/value object. e.g{ '/assets/(.*)': '/js/$1' }. Please checkout koa-rewrite for detail.schemas(String): Defining schemas files directory. Defaults to"schemas".ssl(Boolean|Object): Enable SSL. Defaults tofalse. Here are available props for object config:enable(Boolean): Enablessl. Defaults totrue.port(Number): HTTPS server port.key(String): Key file path.cert(String): Cert file path.
static(Boolean|String|Object): Defining static directory. Defaults to"static".- Setting
falseto disable this feature - Setting a
<dir>string to define directory path - Setting an
objectto forward the options to koa-send. But please note:- You must define an extra
dirprop for static directory gzipoption will always NOT work, please usecompressoption inclaypotconfiguration instead- New
matchoption (using multimatch) for filtering paths maxAgeoption will be0on.htmlfile by default. That means it will NOT cache HTML file by default- If you want to make
maxAgework on.htmlfile, please setcacheHtmlFile: true
- You must define an extra
- Setting
watch(Boolean|Object): Enable watch mode. Defaults tofalse. Not available instartPuremethod. Here are available props for object config:enable(Boolean): Enablewatch. Defaults totrue.dirs(String|[String]): Defining watching directories.ignoreDotFiles(Boolean): Ignore watching.*files. Defaults totrue.ignoreNodeModulesDir(Boolean): Ignore watchingnode_modulesdirectory. Defaults totrue.