7th-saga/web/server.js
2021-02-15 09:18:01 -08:00

45 lines
958 B
JavaScript

const express = require('express');
const path = require('path');
const enemies = require('../data/enemies.json');
const calc = require('../data/calc');
const spells = require('../data/spells');
const items = require('../data/items');
const exp = require('../data/exp');
const app = express();
app.set('view engine', 'pug');
app.set('views', path.join(__dirname, 'views'));
app.set('cache views', false);
app.use(express.static(path.join(__dirname)));
app.get([ '/', '/enemies' ], (req, res) => {
res.render('enemies', {
context: 'enemies',
enemies,
});
});
app.get('/spells', (req, res) => {
res.render('spells', {
context: 'spells',
spells: spells.spells,
});
});
app.get('/exp', (req, res) => {
res.render('exp', {
context: 'exp',
exp: exp.exp,
});
});
const port = process.env.PORT || 18000;
const server = app.listen(port, () => {
const addr = server.address();
console.log(`listening on ${addr.address}:${addr.port}`);
});