Files
node-code/index.js
T
Gitea 79008d0c7c
Node API Test / test (push) Successful in 25s
seventh commit
2026-04-20 09:53:53 +05:30

29 lines
585 B
JavaScript

const express = require("express");
const app = express();
app.use(express.json());
app.get("/", (req, res) => {
res.json({
status: "OK",
message: "Home Route Working Fine"
});
});
app.get("/health", (req, res) => {
res.json({
status: "OK",
message: "Server is healthy"
});
});
module.exports = app;
// only start server if not testing
// It ensures the server starts only when the file is run directly, not when it is imported for testing.
if (require.main === module) {
app.listen(3000, () => {
console.log("Server running on port 3000");
});
}