1.0.3 • Published 4 years ago

@nerjs/express v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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 nametypedefaultdescription
loggerString | Function'dev'settings for morgan
viewsStringpath to views dir. View engine: ejs
bodyJsonBooleantrueuse body-parser method json()
bodyUrlcodedBoolean | Objecttrueuse body-parser method urlencoded()
cookiesBooleantrueuse cookie-parser
faviconStringpath to faficon. Use serve-favicon
staticString | Stringuse 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

:link: All utils