feat(middleware): scaffold Node.js/Express/TypeScript project with health endpoint
- package.json with express, better-sqlite3, mqtt, pg, bcrypt, jsonwebtoken, cors - tsconfig.json targeting ES2022/commonjs - src/index.ts with GET /health on port 4000 - vitest.config.ts for test runner configuration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b1085e1ea4
commit
00968a4626
5423
display/middleware/package-lock.json
generated
Normal file
5423
display/middleware/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
36
display/middleware/package.json
Normal file
36
display/middleware/package.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "display-middleware",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Middleware backend for ESP32 e-paper display system",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "tsx watch src/index.ts",
|
||||||
|
"build": "tsc",
|
||||||
|
"start": "node dist/index.js",
|
||||||
|
"test": "vitest run",
|
||||||
|
"test:watch": "vitest"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bcrypt": "^5.1.1",
|
||||||
|
"better-sqlite3": "^9.6.0",
|
||||||
|
"cors": "^2.8.6",
|
||||||
|
"express": "^4.22.1",
|
||||||
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"mqtt": "^5.15.1",
|
||||||
|
"pg": "^8.20.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bcrypt": "^5.0.2",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
|
"@types/express": "^4.17.25",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
|
"@types/node": "^20.19.39",
|
||||||
|
"@types/pg": "^8.20.0",
|
||||||
|
"@types/supertest": "^6.0.3",
|
||||||
|
"supertest": "^6.3.4",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vitest": "^1.6.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
display/middleware/src/index.ts
Normal file
20
display/middleware/src/index.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import cors from 'cors';
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.get('/health', (_req, res) => {
|
||||||
|
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||||
|
});
|
||||||
|
|
||||||
|
if (require.main === module) {
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
console.log(`Middleware server running on port ${PORT}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default app;
|
||||||
19
display/middleware/tsconfig.json
Normal file
19
display/middleware/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "commonjs",
|
||||||
|
"lib": ["ES2022"],
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"sourceMap": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist", "tests"]
|
||||||
|
}
|
||||||
10
display/middleware/vitest.config.ts
Normal file
10
display/middleware/vitest.config.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
globals: true,
|
||||||
|
environment: 'node',
|
||||||
|
include: ['tests/**/*.test.ts'],
|
||||||
|
testTimeout: 10000,
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user