the statusphere demo reworked into a vite/react app in a monorepo

tidy router

dholms ef772a14 9990f3e3

+18 -15
+15
src/router.ts
··· 1 + import express from "express"; 2 + import { Post } from "#/db"; 3 + 4 + const router = express.Router(); 5 + 6 + router.get("/", async (req, res) => { 7 + const posts = await Post.findAll({ 8 + order: [["createdAt", "DESC"]], 9 + limit: 10, 10 + }); 11 + const texts = posts.map((p) => p.dataValues.text); 12 + res.json(texts); 13 + }); 14 + 15 + export default router;
-13
src/routes.ts
··· 1 - import type express from "express"; 2 - import { Post } from "#/db"; 3 - 4 - export const addRoutes = (app: express.Application) => { 5 - app.get("/", async (req, res) => { 6 - const posts = await Post.findAll({ 7 - order: [["createdAt", "DESC"]], 8 - limit: 10, 9 - }); 10 - const texts = posts.map((p) => p.dataValues.text); 11 - res.json(texts); 12 - }); 13 - };
+3 -2
src/server.ts
··· 11 11 import { env } from "#/common/utils/envConfig"; 12 12 import { Database } from "#/db"; 13 13 import { Firehose } from "#/firehose"; 14 - import { addRoutes } from "#/routes"; 14 + import router from "#/router"; 15 15 16 16 export class Server { 17 17 constructor( ··· 45 45 // Request logging 46 46 app.use(requestLogger); 47 47 48 - addRoutes(app); 48 + // Routes 49 + app.use(router); 49 50 50 51 // Error handlers 51 52 app.use(errorHandler());