Skip to content

Web framework for backend NodeJS, Typescript applications based on routing-controllers

Notifications You must be signed in to change notification settings

melmedia/node-ts-framework

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

142 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS and Typescript REST microservice framework

Boilerplate

Yeoman generator

Performance tests for routing-controllers, typeorm, log4js.

Usage

Bootstrap:

import { Container } from 'inversify';
import { Connection, getRepository, Repository } from 'typeorm';
import {
  Module,
  WebApplication,
  ClusteredWebApplication,
  Environment,
  middlewares,
} from '@melmedia/node-ts-framework';
import { Type } from './Type';

export class AppModule extends Module {

  public async initDiContainer(container: Container) {
    container.bind<Connection>(Type.DbConnection)
      .toConstantValue(await (new components.DbConnectionFactory).create([this]));

  }

  protected get baseDirectory() {
    return __dirname;
  }

}

const modules = [new AppModule];
const app = Environment.Development === process.env.PROJECT_ENV ?
  new WebApplication(modules, [middlewares.ErrorHandlingMiddleware]) :
  new ClusteredWebApplication(modules, [middlewares.ErrorHandlingMiddleware]);
app.run();

Controller looks like:

@JsonController('/client')
export class ClientController {
  @di.inject(Type.ClientDataRepository)
  protected clientDataRepository!: Repository<Client>;

  @Post('/')
  @HttpCode(201)
  public async create(
    @BodyParam('client', { required: true }) clientForm: CreateClientForm,
    @Res() response: Response,
  ) {
  }
}

About

Web framework for backend NodeJS, Typescript applications based on routing-controllers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%