Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/just-cameron/demo-todo-api. A demo todo application.
Something went wrong. Try again.
682 B · 24 lines
TypeScript
at main
12345678910111213141516171819202122232425import express from "express";import todoRoutes from "./routes/todos";import { authMiddleware } from "./middleware/auth";
const app = express();const PORT = process.env.PORT || 3000;
// Middlewareapp.use(express.json());
// Health check (no auth required)app.get("/health", (req, res) => { res.json({ status: "ok", timestamp: new Date().toISOString() });});
// Protected routesapp.use("/todos", authMiddleware, todoRoutes);
// Start serverapp.listen(PORT, () => { console.log(`Todo API running at http://localhost:${PORT}`); console.log(`Health check: http://localhost:${PORT}/health`); console.log(`Todos (requires auth): http://localhost:${PORT}/todos`);});