Add Express service with health endpoint

This commit is contained in:
Alexa Amundson
2025-11-22 20:25:21 -06:00
parent dde613a012
commit a595148831
6 changed files with 1233 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
dist

1180
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,19 @@
"name": "demo-repo", "name": "demo-repo",
"version": "0.2.0", "version": "0.2.0",
"description": "A sample package.json", "description": "A sample package.json",
"scripts": {
"dev": "ts-node src/index.ts",
"build": "tsc",
"start": "node dist/index.js"
},
"dependencies": { "dependencies": {
"@primer/css": "17.0.1" "@primer/css": "17.0.1",
"express": "^4.19.2"
},
"devDependencies": {
"@types/express": "^4.17.21",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
}, },
"license": "MIT" "license": "MIT"
} }

17
src/index.ts Normal file
View File

@@ -0,0 +1,17 @@
import express from "express";
import path from "path";
import health from "./routes/health";
const app = express();
app.use(health);
app.get("/", (_req, res) => {
res.sendFile(path.join(__dirname, "../index.html"));
});
const port = Number(process.env.PORT) || 8080;
app.listen(port, "0.0.0.0", () => {
console.log(`[blackroad-os-demo] listening on http://0.0.0.0:${port}`);
});

9
src/routes/health.ts Normal file
View File

@@ -0,0 +1,9 @@
import { Router } from "express";
const r = Router();
r.get("/health", (_req, res) => {
res.status(200).json({ status: "ok", service: "blackroad-os-demo" });
});
export default r;

13
tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2019",
"module": "CommonJS",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
"include": ["src/**/*"]
}