base for micro services or simple servers
const service = require('server-base')
service({
'@setup': (ctx, router) => {
ctx.use([
(req, res, next) => next()
])
ctx.onError([
(req, res, error, next) => next()
])
},
'/graphql': {
get (req, res) {
res.end('html')
},
async post (req, res) {
const query = await req.json()
res.json({})
}
}
})
.start(5000)
See server-base-router for details.
See server-base-router-tests for details.
See server-base-log for details.
If a .env file exists it will load the values into process.env using dotenv.
PORT=1900
With npm do:
npm install server-base