import { join } from 'path'
import Koa from 'koa'
import R from 'ramda'
import chalk from 'chalk'
import config from '../config'
const MIDDLEWARES = ['general', 'router']
const useMiddlewares = (app) => {
R.map(
R.compose(
R.forEachObjIndexed(
e => e(app)
),
require,
name => join(__dirname, `./middleware/${name}`)
)
)(MIDDLEWARES)
async function start () {
const app = new Koa()
const { port } = config
await useMiddlewares(app)
const server = app.listen(port, () => {
})
}
start()
-
Notifications
You must be signed in to change notification settings - Fork 0
zyy1688/koa2-load-middleware
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
koa2 批量加载中间件脚本
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published