mirror of
https://github.com/SrIzan10/api.git
synced 2026-06-06 00:46:48 +00:00
fix: database queries not working
This commit is contained in:
4
index.ts
4
index.ts
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -12,6 +12,8 @@ model sern_timezones {
|
||||
v Int @default(0) @map("__v") @ignore
|
||||
timezone String
|
||||
userid String @unique
|
||||
|
||||
@@map("sern-timezones")
|
||||
}
|
||||
|
||||
model transcripts {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user