Express Me
Create production-ready ExpressJS applications
with the most common modules initialized automatically.
Installation
Using npm:
$ npm install express-me --save
Using yarn:
$ yarn add express-me
Usage
const expressMe = require('express-me')
let options = {}
expressMe(options, (app, http) => {
})
expressMe((app, http) => {
})
expressMe(app => {
})
Options
Here is a list of available options:
- bugsnag
Specifies if to send errors to Bugsnag.
Uses the report-error module.
Accepts one of the following values:
false - disable this feature.
String - enable this feature and use provided value as the Bugsnag API key.
Default value: false
- morgan
Specifies if to use morgan logger.
Accepts one of the following values:
false - disable logger.
true - enable a default logger when in development mode.
String - enable logger with given format.
Object - enable logger with given format and options arguments.
Default value: true
- db
Specifies if to connect to the database using
mongoose module.
Accepts one of the following values:
false - disable this feature.
Object - enable this feature and connect using provided connection details.
Default value: false
Connection details object structure:
{
"host": "127.0.0.7",
"port": 27017,
"name": "database_name"
}
- helmet
Specifies if to initialize helmet module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize helmet with default options.
Object - enable this feature and initialize using provided helmet options.
Default value: true
For more details about helmet options
see helmet module.
- compression
Specifies if to initialize compression module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize compression with default options.
Object - enable this feature and initialize using provided compression options.
Default value: true
For more details about compression options
see compression module.
- static
Specify static directories.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and use default static directories.
String, Array - enable this feature and use provided static directories.
Default value: true
let staticDirectories = [
path.join(process.cwd(), 'client', 'dist'),
path.join(process.cwd(), 'client', 'dist', 'favicon')
]
- staticPrefix
Specify if to use a prefix for static files.
Accepts one of the following values:
undefined - do not use a prefix.
String - use it's value as a prefix.
Default value: undefined
- assetVersions
Specifies it to use the
express-asset-versions
module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and use a default directory.
String - enable this feature and use provided value as a directory.
Default value: true
let assetPath = path.join(process.cwd(), 'client', 'dist')
For more details see
express-asset-versions
module.
- views
Specify the directory or directories for the views.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and use a default directory.
String, Array - enable this feature and use provided directories.
Default value: true
let viewsPath = path.join(process.cwd(), 'views')
- viewEngine
Specify the view engine of the application.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and use a default view engine.
String - enable this feature and use provided view engine.
Default value: true
let viewEngine = 'pug'
- cookies
Specifies if to initialize cookie-parser module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize cookie-parser with default options.
String - enable this feature and initialize using provided secret.
Default value: true
For more details about cookie-parser options
see cookie-parser module.
- detectIp
Specifies if to initialize detect-ip module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize detect-ip with default options.
Object - enable this feature and initialize using provided options.
Default value: true
For more details about detect-ip options
see detect-ip module.
- ipCountry
Specifies if to initialize ip-country module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize ip-country with default options.
Object - enable this feature and initialize using provided options.
Default value: true
For more details about ip-country options
see ip-country module.
- i18n
Specifies if to initialize i18n module.
Accepts one of the following values:
false - disable this feature.
Object - enable this feature and initialize using provided options.
Default value: false
For more details about i18n options
see i18n module.
- cdnjs
Specifies if to initialize cdnjs-env module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize cdnjs-env with default options.
Default value: true
For more details about cdnjs-env options
see cdnjs-env module.
- localPrice
Specifies if to initialize local-price module.
Accepts one of the following values:
false - disable this feature.
true - enable this feature and initialize local-price with default options.
String - enable this feature and set the given default currency.
Default value: true
- errorHandler
Define a custom error handler.
more details
When not provided a default error handler is used.
- errorView
Specify a full path to a view which will be rendered on errors.
When not provided a default error handler is used.
- port
Specify a port for the application.
Default value: 3000
Used modules
License
The MIT License (MIT)
Copyright (c) 2017 Ion Suman sumanion122@gmail.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.