middlehorse

2019-03-15 admin

middlehorse是什么

什么是middlehorse,A handy tool for Express Node.js apps to quickly implement the usual middleware with options set in a config file/object.

middlehorse使用教程帮助文档

Middlehorse

A member of the nüzu family

A handy tool for Express Node.js apps to quickly implement the usual middleware with options set in a config file.

Includes

  • serving static files via express.static
  • console logging via supported loggers (currently just morgan)
  • body-parser
  • cookie-parser
  • cors
  • templating engines that are also supported by consolidate.js

Installation

npm install middlehorse --save

Usage

import express from 'express'
import middlehorse from 'middlehorse'

const app = express()

const middlehorseConfig = {
  static: {
    disable: false,
    path: 'file',
    staticFolder: 'public'
  },
  logging: {
    logger: 'morgan',
    loggerFormat: 'combined'
  },
  bodyParser: {
    json: true,
    urlEncoded: true
  }
}

middlehorse(app, middlehorseConfig)

app.listen(4000)

middlehorse API

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-57721.html

文章标题:middlehorse

回到顶部