feat(api): scaffold express server with /api/health endpoint
This commit is contained in:
parent
04acd4b580
commit
a0f008be74
4 changed files with 34 additions and 1 deletions
|
|
@ -3,8 +3,18 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "tsx watch src/server.ts",
|
||||||
|
"build": "tsc",
|
||||||
|
"start": "node dist/server.js"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@glossa/db": "workspace:*",
|
||||||
"@glossa/shared": "workspace:*",
|
"@glossa/shared": "workspace:*",
|
||||||
"@glossa/db": "workspace:*"
|
"express": "^5.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/express": "^5.0.6",
|
||||||
|
"tsx": "^4.21.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
apps/api/src/app.ts
Normal file
12
apps/api/src/app.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import express from "express";
|
||||||
|
import type { Express } from "express";
|
||||||
|
|
||||||
|
export function createApp() {
|
||||||
|
const app: Express = express();
|
||||||
|
|
||||||
|
app.get("/api/health", (_req, res) => {
|
||||||
|
res.json({ status: "ok" });
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
||||||
9
apps/api/src/server.ts
Normal file
9
apps/api/src/server.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { createApp } from "./app.js";
|
||||||
|
|
||||||
|
const PORT = Number(process.env["PORT"] ?? 3000);
|
||||||
|
|
||||||
|
const app = createApp();
|
||||||
|
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
console.log(`Server listening on port ${PORT}`);
|
||||||
|
});
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
"types": ["vitest/globals"],
|
"types": ["vitest/globals"],
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue