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
15
src/services/database.ts
Normal file
15
src/services/database.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { sequelize } from "../config/database.js";
|
||||
|
||||
export async function getUtcTimestamp(): Promise<string | null> {
|
||||
if (!sequelize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const [results] = await sequelize.query("SELECT NOW() AS utc_time");
|
||||
const rows = results as { utc_time: string }[];
|
||||
return rows[0]?.utc_time ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue