fix: database queries not working

This commit is contained in:
2023-10-24 15:50:51 +02:00
parent 62e9f6030e
commit 43a548eab0
5 changed files with 7 additions and 17 deletions

View File

@@ -10,7 +10,7 @@ const exec = (await import('util')).promisify((await import('child_process')).ex
const dirname = path.dirname(fileURLToPath(import.meta.url));
await exec('npx prisma generate')
if (process.argv[2] !== '--dev') await exec('npx prisma generate')
/* MongoDB */
export const prisma = new PrismaClient()
@@ -19,7 +19,7 @@ export const prisma = new PrismaClient()
const app = express()
const limiter = rateLimit({
windowMs: 1 * 60 * 1000,
max: 10,
max: 30,
message: { success: false, reason: "you just got ratelimited", error: "You just got ratelimited." },
standardHeaders: true,
})

View File

@@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "tsc-watch --onSuccess \"node dist/index.js\"",
"dev": "tsc-watch --onSuccess \"node dist/index.js --dev\"",
"build": "tsc --build"
},
"repository": {

View File

@@ -12,6 +12,8 @@ model sern_timezones {
v Int @default(0) @map("__v") @ignore
timezone String
userid String @unique
@@map("sern-timezones")
}
model transcripts {

View File

@@ -3,15 +3,6 @@ import type { Handler } from 'express'
export const del: Handler = async (req, res) => {
if (req.query.userid && req.query.key === process.env.SERN_TIME) {
if (
await prisma.sern_timezones.findUnique({
where: { userid: req.query.userid as string },
})
)
return res.status(400).json({
error: "the user doesn't exist",
})
await prisma.sern_timezones.delete({
where: {
userid: req.query.userid as string,

View File

@@ -3,15 +3,12 @@ import type { Handler } from "express"
export const get: Handler = async (req, res) => {
if (req.query.userid) {
if (await prisma.sern_timezones.count({ where: { userid: req.query.userid as string } }) === 0)
return res.status(400).json({
error: "the user doesn't exist",
})
const timezone = await prisma.sern_timezones.findUnique({
where: {
userid: req.query.userid as string,
}
})
})
if (!timezone) return res.status(400).json({ error: "the user doesn't exist" })
res.json({ timezone: timezone?.timezone })
} else {
res.status(400).json({