@tekbox/rest-express
TypeScript icon, indicating that this package has built-in type declarations

0.1.17 • Public • Published

@tekbox/rest-express

Basic express server with decorators for simple routing.

Usage:

Define a route:

export class TestRoute extends BaseRoute {

    @Route.GET("/")
    test(req: express.Request, res: express.Response) {
        res.send("GET: Hello World");
    }

    @Route.POST("/")
    test1(req: express.Request, res: express.Response) {
        res.send("POST: Hello World");
    }

    @Route.PUT("/")
    test2(req: express.Request, res: express.Response) {
        res.send("PUT: Hello World");
    }

    @Route.PATCH("/")
    test3(req: express.Request, res: express.Response) {
        res.send("PATCH: Hello World");
    }

    @Route.DELETE("/")
    test4(req: express.Request, res: express.Response) {
        res.send("DELETE: Hello World");
    }
}

Define app and register routes:

export class TestApp extends AbstractExpressApp {
        
    /*
     * Register routes 
     */
    protected setupAdditionalFilterChain() {
            const routes = [new CORSRoute(), new AuthRoute(), new BandRoute(), new AppRoute()];
            this.filterChain.push(new RouterMiddleware(routes));
        }
}

Start server:

const defaultServer = new DefaultServer(3000, new TestApp());
defaultServer.start();

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.170latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.170
0.1.160
0.1.150
0.1.140
0.1.130
0.1.110
0.1.100
0.1.90
0.1.80

Package Sidebar

Install

npm i @tekbox/rest-express

Weekly Downloads

0

Version

0.1.17

License

none

Unpacked Size

93.8 kB

Total Files

76

Last publish

Collaborators

  • r1co