Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as Express from 'express';
- import { injectable } from 'inversify';
- import { Controller , Get } from 'inversify-express-utils';
- import CommandRepository from 'server/repository/command.ts';
- function middleware1( req: Express.Request , res: Express.Response , next: Function ) {
- console.log( 'middleware1' );
- next();
- }
- function middleware2( req: Express.Request , res: Express.Response , next: Function ) {
- console.log( 'middleware2' );
- next();
- }
- function controllerMiddleware( req: Express.Request , res: Express.Response , next: Function ) {
- console.log( 'controller-middleware' );
- next();
- }
- @Controller( '/' )
- @injectable()
- export default class HomeController {
- private commandRepository: CommandRepository;
- constructor( commandRepository: CommandRepository ) {
- this.commandRepository = commandRepository;
- console.log( this.commandRepository , typeof this.commandRepository );
- }
- @Get( '/test' )
- public test( req: Express.Request , res: Express.Response ) {
- res.send( { status: true } );
- }
- @Get( '/test-with-middleware' , middleware1 , middleware2 )
- public testWithMiddlewaare( req: Express.Request , res: Express.Response ) {
- res.send( { status: true } );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement