Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// No cache
app.use((req, res, next) => {
res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', '-1');
next();
});
// Read and swagger config file
const apiDefinition = yamljs_1.default.load(path_1.default.resolve(__dirname, 'swagger.yml'));
// Create mock functions based on swaggerConfig
const options = {
security: {
AccessTokenAuth: security_1.accessTokenAuth
}
};
const connectSwagger = connector(api, apiDefinition, options);
connectSwagger(app);
// Print swagger router api summary
const apiSummary = summarise(apiDefinition);
console.log(apiSummary);
// Catch 404 error
app.use((req, res, next) => {
const err = new Error('Not Found');
res.status(404).json({
message: err.message,
error: err
});
});
// Create HTTP server.
const server = http_1.default.createServer(app);
// Listen on provided port, on all network interfaces.
server.listen(port);
res.header('Pragma', 'no-cache');
res.header('Expires', '-1');
next();
});
// Read and swagger config file
const apiDefinition = yamljs_1.default.load(path_1.default.resolve(__dirname, 'swagger.yml'));
// Create mock functions based on swaggerConfig
const options = {
security: {
AccessTokenAuth: security_1.accessTokenAuth
}
};
const connectSwagger = connector(api, apiDefinition, options);
connectSwagger(app);
// Print swagger router api summary
const apiSummary = summarise(apiDefinition);
console.log(apiSummary);
// Catch 404 error
app.use((req, res, next) => {
const err = new Error('Not Found');
res.status(404).json({
message: err.message,
error: err
});
});
// Create HTTP server.
const server = http_1.default.createServer(app);
// Listen on provided port, on all network interfaces.
server.listen(port);
server.on('error', onError);
console.log('Mock server started on port ' + port + '!');
// Event listener for HTTP server "error" event.