fix DB table creation, remove log line
This commit is contained in:
@@ -2,6 +2,7 @@ import { default as gist } from "./api/gist.js";
|
||||
import { default as pin } from "./api/pin.js";
|
||||
|
||||
export default async (req, res) => {
|
||||
// remaining code expects express.js-like request and response objects
|
||||
res.send = function (data) {
|
||||
if (typeof data === "object") {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
@@ -17,20 +18,6 @@ export default async (req, res) => {
|
||||
const url = new URL(req.url, "https://localhost");
|
||||
req.query = Object.fromEntries(url.searchParams.entries());
|
||||
|
||||
console.log(
|
||||
JSON.stringify(req.query) +
|
||||
" # " +
|
||||
req.method +
|
||||
" # " +
|
||||
JSON.stringify(req.headers) +
|
||||
" # " +
|
||||
res.setHeader +
|
||||
" # " +
|
||||
res.send +
|
||||
" # " +
|
||||
res.status,
|
||||
);
|
||||
|
||||
switch (url.pathname) {
|
||||
case "/gist":
|
||||
gist(req, res);
|
||||
|
||||
@@ -39,7 +39,8 @@ export async function storeRequest(req) {
|
||||
const createTableQuery = `
|
||||
CREATE TABLE IF NOT EXISTS requests (
|
||||
request TEXT PRIMARY KEY,
|
||||
requested_at TIMESTAMP NOT NULL DEFAULT now()
|
||||
requested_at TIMESTAMP NOT NULL DEFAULT now(),
|
||||
user_requested_at TIMESTAMP NOT NULL DEFAULT now()
|
||||
)
|
||||
`;
|
||||
await pool.query(createTableQuery);
|
||||
|
||||
Reference in New Issue
Block a user