diff options
| author | Andrew Lee <andrew@alee14.me> | 2026-04-09 01:22:38 -0400 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2026-04-09 01:22:38 -0400 |
| commit | f8b93cf133126b57d85d8a5fc424fc87ad2f4459 (patch) | |
| tree | 53f16e8c0a2d65b1df1981292bdaa736ec1e1e76 /api/index.ts | |
| download | bnbmc-announcement-api-f8b93cf133126b57d85d8a5fc424fc87ad2f4459.tar.gz bnbmc-announcement-api-f8b93cf133126b57d85d8a5fc424fc87ad2f4459.tar.bz2 bnbmc-announcement-api-f8b93cf133126b57d85d8a5fc424fc87ad2f4459.zip | |
Initial commit
Diffstat (limited to 'api/index.ts')
| -rw-r--r-- | api/index.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/api/index.ts b/api/index.ts new file mode 100644 index 0000000..2fb7a08 --- /dev/null +++ b/api/index.ts @@ -0,0 +1,17 @@ +import express from 'express'; +import { Database } from "bun:sqlite"; + +const app = express(); +const port = process.env.PORT || 3000; +const db = new Database("../database.sqlite", { readonly: true }); + + +app.get('/', (req, res) => { + const query = db.prepare(`SELECT * FROM announcements ORDER BY created_at DESC`); + const result = query.all(); + res.send(result); +}); + +app.listen(port, () => { + console.log(`Server is running on port ${port}`); +}); |
