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): Injectclay
object to middleware context. Defaults totrue
.compress
(Boolean|Object): Compress (gzip) static files. Defaults totrue
inproduction
mode,false
indevelopment
mode. Please Note thattrue
will 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 instartPure
method.daemon
(Boolean): Enabledaemon
mode. Notice: to killdaemon
process, please runclaypot stop ${name}
. Defaults tofalse
. Not available instartPure
method.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 instartPure
method.execArgs
(String|[String]): Executing arguments. Defaults to[]
. Not available instartPure
method.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 instartPure
method.favicon
(Boolean|String): Defining favicon. Settingfalse
to disable this feature. Setting a path string to set a custom favicon file. Defaults totrue
.helmet
(Boolean|Object): Enable helmet for safety. Defaults totrue
inproduction
mode,false
indevelopment
mode.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 instartPure
method.logLevel
(String|Object): Defining log level. See pot-logger for detail. Here are available levels:- ALL
- TRACE
- DEBUG (default in
development
mode) - INFO (default in
production
mode) - WARN
- ERROR
- FATAL
- OFF
logsDir
(String): Defining log files directory. Ifdaemon
mode actived, log messages will write to some.log
files. Defaults to".logs"
.maxRestarts
(Number): Defining max restarts if crashed. Defaults to-1
(-1
equals toInfinity
) inproduction
mode,0
indevelopment
mode. Not available instartPure
method.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 totrue
indevelopment
mode. Not available instartPure
method.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): Enableproduction
mode. Defaults totrue
.proxy
(Object): Defining HTTP proxies. e.g.{ '/my/path/': 'http://anti.proxy.com/' }
. See HTTP Proxy for detail.responseTime
(Boolean): Enablex-response-time
to 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
false
to disable this feature - Setting a
<dir>
string to define directory path - Setting an
object
to forward the options to koa-send. But please note:- You must define an extra
dir
prop for static directory gzip
option will always NOT work, please usecompress
option inclaypot
configuration instead- New
match
option (using multimatch) for filtering paths maxAge
option will be0
on.html
file by default. That means it will NOT cache HTML file by default- If you want to make
maxAge
work on.html
file, please setcacheHtmlFile: true
- You must define an extra
- Setting
watch
(Boolean|Object): Enable watch mode. Defaults tofalse
. Not available instartPure
method. 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_modules
directory. Defaults totrue
.