-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 1.15 KB
/
app.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
33
34
35
36
37
38
39
40
41
42
43
import fastify from 'fastify';
import packageData from './package.json' assert {type: "json"};
import dotenv from 'dotenv';
dotenv.config()
// Site Routes
import siteRoutes from './routes'
//
// Application Boot
//
const buildApp = async () => {
const app = fastify({ logger: process.env.DEBUG });
try {
app.register((instance, options, next) => {
// Routes
siteRoutes(instance);
next();
});
const port = process.env.PORT;
app.listen({ port: port, host: '0.0.0.0' }, (err) => {
if (err) {
app.log.error(err);
process.exit(1);
}
})
console.log(`\n// ${packageData.name} v.${packageData.version}\nGitHub Repository: ${packageData.homepage}\nCreated By: ${packageData.author}`);
console.log(`API is listening to the port ${process.env.PORT}`);
} catch (error) {
app.log.error(`Unable to start the server:\n${error}`);
}
};
buildApp();
export function removeHtmlEntities(str) {
return str.replace(/“|”|—|’|“|”|‘|–|…|″|‶/g, '');
}