-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 912 Bytes
/
index.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
import express from 'express';
import bodyParser from 'body-parser';
import Chance from 'chance';
import compression from 'compression';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import page from './src/page.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const PORT = process.env.PORT || 3000;
const app = express();
const chance = new Chance();
let username = '';
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/dist'));
app.use(express.static(__dirname + '/node_modules/htmx.org/dist'));
app.use(express.static(__dirname + '/assets'));
app.use(compression());
app.get('/', (req, res) => {
username = chance.name();
res.send(page(req.query));
});
app.get('/htmx/:id', (req, res) => {
res.send('<h4>hello</h4>');
});
app.listen(PORT);
console.log('root app listening on port:', PORT);