35 lines
881 B
JavaScript
35 lines
881 B
JavaScript
const fastify = require('fastify')();//{ logger: true });
|
|
const path = require('path');
|
|
|
|
fastify.register(require('@fastify/static'), {
|
|
root: path.join(__dirname, 'public'),
|
|
prefix: '/public/',
|
|
});
|
|
|
|
fastify.register(require('@fastify/leveldb'), {
|
|
name: 'db'
|
|
}, err => {
|
|
if (err) throw err
|
|
});
|
|
|
|
fastify.register(require("@fastify/view"), {
|
|
engine: {
|
|
pug: require("pug"),
|
|
},
|
|
});
|
|
|
|
|
|
fastify.register(require('./router/api'), { prefix: '/api' });
|
|
|
|
|
|
fastify.get('/', (req, reply) => reply.view("/template/home.pug", ));
|
|
fastify.get('/:id', (req, reply) => reply.view('/template/journey.pug'));
|
|
fastify.get('/view/:id', (req, reply) => reply.view('/template/view.pug'));
|
|
fastify.get('/short/:id', (req, reply) => reply.view('/template/short.pug'));
|
|
|
|
|
|
fastify.listen({port:8080,host:'0.0.0.0'} ,(err,address) => {
|
|
if (err) throw err;
|
|
console.log("Listening on", address);
|
|
|
|
}); |