-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (24 loc) · 814 Bytes
/
server.js
File metadata and controls
30 lines (24 loc) · 814 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
require('dotenv').config();
const config = require('./config/config');
const fastify = require('fastify')({ logger: true });
fastify.register(require('fastify-jwt'), { secret: config.JWT_SECRET });
fastify.register(require('fastify-auth'));
fastify.register(require('./routes/routes'));
fastify.register(require('fastify-cors'), {});
require('./models/models_sync');
const path = require('path');
fastify.register(require('fastify-static'), {
root: path.join(__dirname, 'public'),
prefix: '/public/', // optional: default '/'
});
// Run the server!
const start = async () => {
try {
await fastify.listen(3000);
fastify.log.info(`server listening on ${fastify.server.address().port}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};
start();