-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (27 loc) · 793 Bytes
/
server.js
File metadata and controls
32 lines (27 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const path = require('path');
const config = require('config');
const fs = require('fs');
const initDecorators = require('./decorators');
const initPlugins = require('./plugins');
const initRoutes = require('./routes');
const fastify = require('fastify')({
logger: true,
http2: true,
https: {
allowHTTP1: true, // fallback support for HTTP1
key: fs.readFileSync(path.join(__dirname, '.cert', 'key.pem')),
cert: fs.readFileSync(path.join(__dirname, '.cert', 'cert.pem')),
},
});
initDecorators(fastify);
initPlugins(fastify);
initRoutes(fastify);
// Run the server!
fastify.listen({ port: config.port }, (err, address) => {
if (err) {
fastify.log.error(err);
process.exit(1);
}
fastify.log.info(`Server is now listening on ${address}`);
});