-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
50 lines (43 loc) · 1.23 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
44
45
46
47
48
49
50
const path = require('path');
const app = require('fastify')({
logger: true
})
const retrieveJobs = require('./utils/retrieveJobs')
const isProduction = process.env.NODE_ENV === 'production'
const outputDir = path.join(__dirname, 'static')
const argv = require('yargs').argv
const jobQuery = argv.job ? argv.job : 'Front end';
require('lasso').configure({
plugins: [
'lasso-marko' // Allow Marko templates to be compiled and transported to the browser
],
outputDir: outputDir,
bundlingEnabled: isProduction,
minify: isProduction,
fingerprintsEnabled: isProduction,
});
// Register marko template engine
app.register(require("point-of-view"), {
engine: {
marko: require("marko")
}
});
// Register static file directory
app.register(require('fastify-static'), {
root: outputDir,
prefix: '/static'
});
// Get Routes
app.get('/', async (request, reply) => {
await retrieveJobs(jobQuery).then((result) => {
//console.log(result.stackoverflow)
reply.view('/templates/index.marko', result)
}, (err) => {
console.error(err);
})
});
// Start server
app.listen(3000, (err, address) => {
if (err) throw err
app.log.info(`server listening on ${address}`)
})