Upgrading nextjs and collect (#3252)
* Upgrading nextjs and collect * Fixing suggestions + yarn.lock * Updating submodules Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c3c7f82841
commit
b1d637d1a6
14 files changed
+51
-358
No files matched your search
@@ -15,6 +15,14 @@ import path from "path";
|
||||
*/
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const [appName, fileName] = Array.isArray(req.query.static) ? req.query.static : [req.query.static];
|
||||
|
||||
if (!fileName) {
|
||||
return res.status(400).json({ error: true, message: "No file name provided" });
|
||||
}
|
||||
if (!appName) {
|
||||
return res.status(400).json({ error: true, message: "No app name provided" });
|
||||
}
|
||||
|
||||
const fileNameParts = fileName.split(".");
|
||||
const { [fileNameParts.length - 1]: fileExtension } = fileNameParts;
|
||||
const STATIC_PATH = path.join(process.cwd(), "..", "..", "packages/app-store", appName, "static", fileName);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import z from "zod";
|
||||
|
||||
import jackson from "@lib/jackson";
|
||||
|
||||
@@ -12,6 +13,10 @@ const extractAuthToken = (req: NextApiRequest) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
const requestQuery = z.object({
|
||||
access_token: z.string(),
|
||||
});
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
if (req.method !== "GET") {
|
||||
@@ -24,7 +29,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
// check for query param
|
||||
if (!token) {
|
||||
let arr: string[] = [];
|
||||
arr = arr.concat(req.query.access_token);
|
||||
const { access_token } = requestQuery.parse(req.query);
|
||||
arr = arr.concat(access_token);
|
||||
if (arr[0].length > 0) {
|
||||
token = arr[0];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { pick } from "lodash";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import z from "zod";
|
||||
|
||||
import { getSession } from "@lib/auth";
|
||||
import prisma from "@lib/prisma";
|
||||
@@ -11,8 +12,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
return res.status(401).json({ message: "Not authenticated" });
|
||||
}
|
||||
|
||||
const userIdQuery = req.query?.id ?? null;
|
||||
const userId = Array.isArray(userIdQuery) ? parseInt(userIdQuery.pop() || "") : parseInt(userIdQuery);
|
||||
const querySchema = z.object({
|
||||
id: z.string().transform((val) => parseInt(val)),
|
||||
});
|
||||
|
||||
const parsedQuery = querySchema.safeParse(req.query);
|
||||
const userId = parsedQuery.success ? parsedQuery.data.id : null;
|
||||
|
||||
if (!userId) {
|
||||
return res.status(400).json({ message: "No user id provided" });
|
||||
}
|
||||
|
||||
const authenticatedUser = await prisma.user.findFirst({
|
||||
rejectOnNotFound: true,
|
||||
|
||||
Reference in new issue
Block a user