Leajs
extendable, configuration based http server.
Features
- Snapshots only - forces you to do proper tests of input -> output
- Interactively shows you the output and asks about it
- Uses webpack bundles to track changes
- Watches test files and dependencies
- Static analysis of tests to make writing them as easy as possible
Install
npm install --save leajs-server
Usage
# cli
usage: leajs <options> (config file)
options:
-w, --watch restart server on changes in config
-p, --prod sets NODE_ENV to "production"
--port [port] opens server on [port]
config file is optional and defaults to "leajs.config.[js|json|coffee|ts]"
in "server/" and "/"
Leajs = require("leajs-server")
Leajs(options)
.then((leajs) => {
leajs.close()
})
.catch((e) => {
})
leajs.config
Read by read-conf, from ./
or ./server/
by default.
module.exports = {
base: "",
disablePlugins: null,
index: "index.html",
listen: {
host: null,
port: null,
},
plugins: ["leajs-files","leajs-folders","leajs-encoding","leajs-cache","leajs-locale","leajs-eventsource","leajs-redirect"],
respond: null,
verbose: 1,
}
Custom respond function
module.exports = {
respond: (req) => {
if (req.url == "/hello"){
req.body = "hello world!"
}
}
}
Plugins
You should read the (short) docs of the bold ones.
Activated by default:
Installed and activated manually
License
Copyright (c) 2018 Paul Pflugradt
Licensed under the MIT license.