feat: add minimal frontend and backend CI demo
This commit is contained in:
26
be/server.js
Normal file
26
be/server.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const { createServer } = require("node:http");
|
||||
|
||||
const port = Number(process.env.PORT || 8080);
|
||||
|
||||
function sendJson(response, status, body) {
|
||||
response.writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
||||
response.end(JSON.stringify(body));
|
||||
}
|
||||
|
||||
const server = createServer((request, response) => {
|
||||
const pathname = new URL(request.url || "/", "http://localhost").pathname;
|
||||
|
||||
if (request.method === "GET" && (pathname === "/" || pathname === "/health")) {
|
||||
return sendJson(response, 200, { status: "ok", service: "be" });
|
||||
}
|
||||
|
||||
if (request.method === "GET" && pathname === "/api/hello") {
|
||||
return sendJson(response, 200, { service: "be", message: "Hello from the backend" });
|
||||
}
|
||||
|
||||
return sendJson(response, 404, { error: "Not found" });
|
||||
});
|
||||
|
||||
server.listen(port, "0.0.0.0", () => {
|
||||
console.log(`BE listening on port ${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user