mirror of
https://github.com/SrIzan10/starters.git
synced 2026-05-01 11:05:16 +00:00
24 lines
464 B
JavaScript
24 lines
464 B
JavaScript
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
|
|
// Call Railway anywhere on serverside code.
|
|
// Here or getInitialProps
|
|
|
|
import pg from "pg";
|
|
|
|
const client = new pg.Pool();
|
|
|
|
export default async (req, res) => {
|
|
try {
|
|
const query = await client.query("SELECT NOW()");
|
|
|
|
res.json({
|
|
data: {
|
|
time: query.rows[0].now,
|
|
},
|
|
});
|
|
} catch (e) {
|
|
console.log("ERROR", e);
|
|
res.json({ error: e });
|
|
}
|
|
};
|