Skip to content

This is a simple library that is built around Express JS to use it with controller classes and decorators

Notifications You must be signed in to change notification settings

scarecrow98/express-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-wrapper

This is a simple library that is built around Express JS to use it with controller classes and decorators My goal was to get to know Typescript more, in particular its metadata and reflection API. This project does not use the reflect-metadata library, it utilizes the built-in Object.getOwnPropertyDescriptor and Object.defineProperty functions to append metadata to classes and methods.

Example

Here's how you would initialize your application:

import { MyController } from  "./app/controllers/my-controller";
import { ExpressWrapperApplication } from  "./core";

const port = 3000;
const app = new ExpressWrapperApplication(port);

app.registerControllers([
	MyController
]);

app.start(() => {
	console.log('server is running...');
});

And here's how you would create a controller class:

import { Request, Response } from  "express";
import { Controller, Get, Post } from  "../../core/decorators";

@Controller('/my')
export class MyController {
    @Get('/test')
    getTest(req: Request, res: Response) {
        res.send('Hello, World!');
    }

    @Post('/test')
    postTest() {
        ...
    }
}

About

This is a simple library that is built around Express JS to use it with controller classes and decorators

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published