sharo
sharo creates an Express app with batteries included.
I created this for easy maintenance of my Node apps; just a single package to upgrade across all apps.
If you want a full-blown boilerplate with additional stuff, check simply-boilerplate.
Installation
Add sharo into dependencies:
$ npm i sharo
Usage
API
createApp([config])
Given a sharo configuration object, generates an Express app according to the configuration.
generateWebpackConfig([config])
Given a sharo configuration object, generates a Webpack configuration object according to the configuration.
Useful if you want to trigger Webpack build by yourself or use the configuration as part of other build tool, for example:
// webpack.config.js
const {generateWebpackConfig} = require('@tkesgar/sharo')
module.exports = generateWebpackConfig(sharoConfig)
// This way you can run 'webpack -p' in shell.
createRouter([options])
Alias to express.Router()
function from express package.
Useful to create routes:
// routes/hello.js
const {createRouter} = require('@tkesgar/sharo')
const router = createRouter()
router.get('/hello', (req, res) => res.send('Hello world!'))
module.exports = router
bunyanSerializers
Alias to bunyan.stdSerializers
array from bunyan package.
Useful to provide serializers in sharo configuration:
// sharo.config.js
const {bunyanSerializers} = require('@tkesgar/sharo')
module.exports = {
// ...
'app-log.serializers': [
...bunyanSerializers,
...customSerializers
]
// ...
}
The module exports a single function that receives a configuration object and returns the Express app:
import sharo from 'sharo'
const app = sharo({/* sharo configuration */})
// Do stuff with app, e.g. create server for HTTP and HTTPS:
http.createServer(app).listen(80)
https.createServer(httpsOptions, app).listen(443)
CLI
sharo-build
Basically just runs Webpack build using the configuration provided by sharo.
sharo-start
Creates the Express app and starts it on PORT (defaults to 1507).
Configurations
TBD
See lib/normalize-config.js
for a list of configurations available.
Sharo?
From Is the Order a Rabbit?.
License
Licensed under MIT License.