express-routemagic
Version:
A simple and fast, fire-and-forget module that all Nodejs+Express app should have, to automatically require all your express routes without bloating your code with `app.use('i/will/repeat/this', require('./i/will/repeat/this')`. 把 Express 路由图给自动化。
20 lines (19 loc) • 862 B
TypeScript
/**
* Uses Route Magic
* @param app The instantiated Express app object.
* @param options Options.
*/
export function use(app: any, options?: {
/** If `invokerPath` is not defined, this is relative to your nodejs ROOT. */
routesFolder?: string
/** If this is defined, `routesFolder` will be relative to this path instead of your nodejs ROOT. */
invokerPath?: string
/** Use your own debug module. */
debug?: function
/** This prints out all your routes. If no debug module is passed, it uses console.log by default. */
logMapping?: boolean
/** `false` by default, i.e. you should not have a `foo.js` and a folder named `foo` sitting at the same level. That's poor organisation. */
allowSameName?: boolean
/** Allows you to skip folders or files with a suffix. */
ignoreSuffix?: string | string[]
}): undefined