secure check-expired-videos endpoint with secret

This commit is contained in:
MarconLP 2023-04-16 01:24:54 +02:00
parent 4c64aeeb35
commit bf202b958c
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5
3 changed files with 32 additions and 5 deletions

27
package-lock.json generated
View file

@ -21,6 +21,7 @@
"@trpc/next": "^10.18.0",
"@trpc/react-query": "^10.18.0",
"@trpc/server": "^10.18.0",
"@upstash/qstash": "^0.3.6",
"axios": "^1.3.5",
"dayjs": "^1.11.7",
"file-saver": "^2.0.5",
@ -1382,6 +1383,11 @@
"node": ">=6.9.0"
}
},
"node_modules/@deno/shim-crypto": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@deno/shim-crypto/-/shim-crypto-0.3.1.tgz",
"integrity": "sha512-ed4pNnfur6UbASEgF34gVxR9p7Mc3qF+Ygbmjiil8ws5IhNFhPDFy5vE5hQAUA9JmVsSxXPcVLM5Rf8LOZqQ5Q=="
},
"node_modules/@esbuild-kit/cjs-loader": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@esbuild-kit/cjs-loader/-/cjs-loader-2.4.2.tgz",
@ -2568,6 +2574,14 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@upstash/qstash": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@upstash/qstash/-/qstash-0.3.6.tgz",
"integrity": "sha512-NKN4jbPhB5lfHoSIaU7AuQ3F+yGS20e/FBRiUuPetcKoi354wHhKj9AJFfkFT5SSeLq0XEsXRNynm8gqCS4HjQ==",
"dependencies": {
"@deno/shim-crypto": "~0.3.0"
}
},
"node_modules/acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
@ -7963,6 +7977,11 @@
"regenerator-runtime": "^0.13.11"
}
},
"@deno/shim-crypto": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@deno/shim-crypto/-/shim-crypto-0.3.1.tgz",
"integrity": "sha512-ed4pNnfur6UbASEgF34gVxR9p7Mc3qF+Ygbmjiil8ws5IhNFhPDFy5vE5hQAUA9JmVsSxXPcVLM5Rf8LOZqQ5Q=="
},
"@esbuild-kit/cjs-loader": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/@esbuild-kit/cjs-loader/-/cjs-loader-2.4.2.tgz",
@ -8653,6 +8672,14 @@
"eslint-visitor-keys": "^3.3.0"
}
},
"@upstash/qstash": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@upstash/qstash/-/qstash-0.3.6.tgz",
"integrity": "sha512-NKN4jbPhB5lfHoSIaU7AuQ3F+yGS20e/FBRiUuPetcKoi354wHhKj9AJFfkFT5SSeLq0XEsXRNynm8gqCS4HjQ==",
"requires": {
"@deno/shim-crypto": "~0.3.0"
}
},
"acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",

View file

@ -27,6 +27,7 @@
"@trpc/next": "^10.18.0",
"@trpc/react-query": "^10.18.0",
"@trpc/server": "^10.18.0",
"@upstash/qstash": "^0.3.6",
"axios": "^1.3.5",
"dayjs": "^1.11.7",
"file-saver": "^2.0.5",

View file

@ -3,8 +3,9 @@ import { prisma } from "~/server/db";
import { DeleteObjectCommand } from "@aws-sdk/client-s3";
import { env } from "~/env.mjs";
import { s3 } from "~/server/aws/s3";
import { verifySignature } from "@upstash/qstash/nextjs";
export default async function handler(
export default verifySignature(async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
@ -52,7 +53,5 @@ export default async function handler(
},
});
res
.status(200)
.json({ name: "John Doe", expiredVideos, updatedVideos, deletedVideos });
}
res.status(200).json({ expiredVideos, updatedVideos, deletedVideos });
});