Created
May 5, 2017 18:02
-
-
Save a0viedo/b0ee4623ef3a31833285d9f9f3008c1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import * as fs from 'fs'; | |
import * as restify from 'restify'; | |
import * as helmet from 'helmet'; | |
if (process.env.NODE_ENV === 'development') { | |
require('dotenv').config(); | |
} | |
import initializeRoutes from './lib/routes'; | |
import logger from './lib/logger'; | |
const server = restify.createServer({ | |
name: require('./package.json').name, | |
version: require('./package.json').version, | |
key: fs.readFileSync('./ssl/server.key'), | |
certificate: fs.readFileSync('./ssl/server.crt') | |
}); | |
server.use(restify.acceptParser(server.acceptable)); | |
server.use(restify.bodyParser()); | |
server.use(restify.queryParser()); | |
server.use(helmet()); | |
server.get('/1', (req, res, next: () => void) => { | |
res.send({ | |
message: 'response with https was successful' | |
}); | |
}); | |
server.listen(443, () => { | |
logger.info('%s listening at %s', server.name, server.url); | |
}); | |
process.on('uncaughtException', (err) => { | |
logger.error('Process encountered an uncaught exception', err); | |
server.close(() => process.exit(1)); | |
}); | |
process.on('unhandledRejection', (err) => { | |
logger.error('Process encountered an unhandled rejection', err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment