feat: add sequelize with postgres UTC timestamp endpoint
This commit is contained in:
parent
1365bd7644
commit
8237c6cd2a
8 changed files with 450 additions and 7 deletions
10
src/index.ts
10
src/index.ts
|
|
@ -1,6 +1,7 @@
|
|||
import express from "express";
|
||||
import { hostname } from "node:os";
|
||||
import { greeting } from "./greeting.js";
|
||||
import { getUtcTimestamp } from "./services/database.js";
|
||||
|
||||
const app = express();
|
||||
const port = Number(process.env.PORT ?? 3000);
|
||||
|
|
@ -20,4 +21,13 @@ app.get("/", (_req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
app.get("/utc-time", async (_req, res) => {
|
||||
const utcTime = await getUtcTimestamp();
|
||||
if (!utcTime) {
|
||||
res.status(503).json({ error: "Database not configured or unavailable" });
|
||||
return;
|
||||
}
|
||||
res.json({ utc_time: utcTime });
|
||||
});
|
||||
|
||||
export { app, port };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue