-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
32 lines (25 loc) · 678 Bytes
/
server.js
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
// Require the framework and instantiate it
const fs = require('fs');
const fastify = require('fastify')({ logger: true,
https: {
requestCert: true,
rejectUnauthorized: true,
key: fs.readFileSync("./certificates/server/serverKey.pem"),
cert: fs.readFileSync("./certificates/server/serverCrt.pem") ,
ca: [fs.readFileSync("./certificates/ca/caCrt.pem")]
}
})
// Declare a route
fastify.get('/', async (request, reply) => {
return { hello: 'world' }
})
// Run the server!
const start = async () => {
try {
await fastify.listen({ port: 3000, host:'0.0.0.0' })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()