1.0.1 • Published 1 year ago

nnx-express-router-factory v1.0.1

Weekly downloads
-
License
GNU
Repository
github
Last release
1 year ago

This is a router factory implementation for Express. If you using Express, you can use this module for creating routers (and end-points).

Quick start

You can install with npm instal command

$ npm install nnx-express-route-factory

and implement like this (to an Express base project);

import express from 'express';
// import 'nnx-route-factory' module
import nnxExpressRouterFactory from 'nnx-express-router-factory';

const app = express();

// create router config
const routerConfig = [
    {
        method: nnxExpressRouterFactory.METHOD.GET,
        path: 'my/path',
        handler: [middlewareFunctiom, myHandlerFunction],
    },
    {
        method: nnxExpressRouterFactory.METHOD.GET,
        path: 'my/other-path',
        handler: myOtherHandlerFunction,
    }
]

// create Express route object
const myRoute = nnxExpressRouterFactory(routerConfig);


// Add route to your Express App
app.use(myRoute);

Reference

Functions

Typedefs

nnxExpressRouterFactory(routerConfig) ⇒ express.Router

Generates express route object.

Kind: global function

ParamType
routerConfigArray.<EndPointConfig>

nnxExpressRouterFactory.METHOD : enum

Kind: static enum of nnxExpressRouterFactory Read only: true Properties

NameTypeDefault
ALLstring"all"
GETstring"get"
HEADstring"head"
POSTstring"post"
PUTstring"put"
DELETEstring"delete"
CONNECTstring"connect"
OPTIONstring"option"
TRACEstring"trace"
PATCHstring"patch"

EndPointConfig : Object

Router end-point config data.

Kind: global typedef Properties

NameType
methodMETHOD
pathString
handlerfunction | Array.<function()>
1.0.1

1 year ago

1.0.0

1 year ago