How to use @decorators/express - 3 common examples

To help you get started, we’ve selected a few @decorators/express examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serhiisol / node-decorators / playground / express / index.ts View on Github external
/**
 * Server configuration
 */

const app: express.Express = express();

app.set('env', 'test');

Container.provide([
  {
    provide: ERROR_MIDDLEWARE,
    useClass: ServerErrorMiddleware
  }
]);

attachControllers(app, [ UserController ]);

app.listen(3000);

console.log('Server is running on http://localhost:3000');
github serhiisol / node-decorators / playground / express / index.ts View on Github external
return new Promise(resolve =>
    setTimeout(resolve, 3000)
  );
}

@Injectable()
class ServerErrorMiddleware implements ErrorMiddleware {

  async use(error, _req, res) {
    await emulatedRequest();

    res.status(500).send(error.toString());
  }
}

@Controller('/')
class UserController {

  @Get('/')
  getData(@Response() res) {
    throw new Error('Handler error');
  }

}

/**
 * Server configuration
 */

const app: express.Express = express();

app.set('env', 'test');
github serhiisol / node-decorators / playground / express / index.ts View on Github external
}

@Injectable()
class ServerErrorMiddleware implements ErrorMiddleware {

  async use(error, _req, res) {
    await emulatedRequest();

    res.status(500).send(error.toString());
  }
}

@Controller('/')
class UserController {

  @Get('/')
  getData(@Response() res) {
    throw new Error('Handler error');
  }

}

/**
 * Server configuration
 */

const app: express.Express = express();

app.set('env', 'test');

Container.provide([
  {

@decorators/express

node decorators - decorators for express library

MIT
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis