-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.mjs
More file actions
50 lines (40 loc) · 1.2 KB
/
main.mjs
File metadata and controls
50 lines (40 loc) · 1.2 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* eslint-disable no-underscore-dangle */
/* eslint-disable import/extensions */
/* eslint-disable no-unused-vars */
/* eslint-disable no-console */
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import Hapi from '@hapi/hapi';
import Inert from '@hapi/inert';
import Vision from '@hapi/vision';
import Handlebars from 'handlebars';
import settings from './src/conf/settings.mjs';
import Routes from './src/routes/index.mjs';
import Models from './src/models/index.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const init = async () => {
const server = Hapi.server(settings.server);
await server.register(Vision);
await server.register(Inert);
server.route(Routes);
await Models.sequelize.sync();
server.views({
engines: {
html: Handlebars,
},
relativeTo: `${__dirname}`,
path: 'src/views',
layoutPath: 'src/views/layout',
layout: 'default',
partialsPath: 'src/views/partials',
helpersPath: 'src/views/helpers',
});
await server.start();
console.log('Server running on %s', server.info.uri);
};
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
init();