Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* 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');
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');
}
@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([
{