1.0.3 • Published 4 years ago
@nerjs/express v1.0.3
express configs
Install
npm i @nerjs/exress
or:
yarn add @nerjs/express
Use
createApp
const createApp = require('@nerjs/express/app')
const app = createApp({/* ...appConfig */})
returns express app
appConfig:
prop name | type | default | description |
---|---|---|---|
logger | String | Function | 'dev' | settings for morgan |
views | String | path to views dir. View engine: ejs | |
bodyJson | Boolean | true | use body-parser method json() |
bodyUrlcoded | Boolean | Object | true | use body-parser method urlencoded() |
cookies | Boolean | true | use cookie-parser |
favicon | String | path to faficon. Use serve-favicon | |
static | String | String | use express.static() |
createHmrApp
Create Hot Module Replacement with express
returns express app
const createHmrApp = require('@nerjs/express/hmr')
create express app with HMR:
use default appConfig
const app = createHmrApp(pathToWebpackConfig)
add HMR to express app
const app = createHmrApp(app, pathToWebpackConfig)
create express app with config and HMR
accepts a appConfig as the first argument
const app = createHmrApp(appConfig, pathToWebpackConfig)
isExpressApp
const isExpressApp = require('@nerjs/express/lib/isExpressApp')
const express = require('express')
const app = express()
isExpressApp(app) == true
isExpressApp({}) == false