diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2023-08-05 21:11:48 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2023-08-05 21:11:48 +0100 |
| commit | 18cc5f69129615850e48a995f7c3406b74d8d2f4 (patch) | |
| tree | 1fdc6eadae4b0a6da69319f9b6733379ced2e4c2 /app/index.ts | |
| parent | 64c36dcef8ab1c0b985d79da627cecd30fd50336 (diff) | |
Redesign website
Diffstat (limited to 'app/index.ts')
| -rw-r--r-- | app/index.ts | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/app/index.ts b/app/index.ts index 8514380..3558d1f 100644 --- a/app/index.ts +++ b/app/index.ts @@ -1,46 +1,56 @@ -import { PageDirectory } from './directory.js'; import express from 'express'; import dotenv from 'dotenv-defaults'; import * as page from './routes/page/router.js'; -import * as special from './routes/special/router.js'; -import { navbar } from './middlewares/index.js' +import * as blog from './routes/blog/router.js'; import { logger } from './logger.js' +import { PageDirectory } from './pages.js'; +// import { SpotifyClient } from './spotify/client.js'; +// import { WebSocketServer } from 'ws'; +// import * as spotifyauth from './routes/spotify/router.js'; +// import * as spotifyWs from './websocket/spotify.js'; + +// TODO: Figure out Spotify's tedious auth flow dotenv.config() const app = express(); -const directory = new PageDirectory(process.env.PAGES_DIR); - app.set('view engine', 'ejs'); app.set('views', 'views'); -app.use(express.static('static')); - -app.use((req, res, next) => { - res.locals.directory = directory; - next(); -}); +app.use(express.static('static', { + etag: true, + maxAge: '1d' +})); +app.use(blog.router); app.use(page.router); -app.use(special.router); +// app.use(spotifyauth.router); -app.use(navbar, (req, res) => { +app.use((req, res) => { res.render('error.ejs', { code: '404', - navbar: res.locals.navbarHtml }); }); const server = app.listen(process.env.PORT, () => { logger.info(`App listening on port ${process.env.PORT}`); }); +// const websocketServer: WebSocketServer = spotifyWs.createWebsocketServer(server); const exit = () => { logger.info('Stopping server...'); + // websocketServer.clients.forEach(client => { + // client.terminate(); + // }); + // websocketServer.close(); server.close(() => { process.exit(0); }) } +PageDirectory.rebuild('pages'); + +// SpotifyClient.initialise(); + process.on('SIGINT', exit); process.on('SIGTERM', exit); |
