From 7d95767ed5fd4dbb997b4404a91d10e64d099b9c Mon Sep 17 00:00:00 2001 From: galnir Date: Wed, 22 Nov 2023 14:02:55 +0200 Subject: [PATCH] use next auth v5 and update deps --- apps/bot/package.json | 46 +- apps/bot/src/lib/music/buttonsCollector.ts | 2 +- apps/bot/src/lib/structures/ExtendedClient.ts | 4 +- apps/dashboard/next.config.mjs | 3 - apps/dashboard/package.json | 54 +- .../src/app/api/trpc/[trpc]/route.ts | 38 +- apps/dashboard/src/components/auth.tsx | 3 - package.json | 12 +- packages/api/package.json | 18 +- packages/auth/index.ts | 3 +- packages/auth/package.json | 16 +- packages/config/eslint/package.json | 22 +- packages/config/tailwind/package.json | 6 +- packages/db/package.json | 10 +- pnpm-lock.yaml | 2162 +++++++++-------- 15 files changed, 1313 insertions(+), 1086 deletions(-) diff --git a/apps/bot/package.json b/apps/bot/package.json index 301b0276f..f0a2a66ed 100644 --- a/apps/bot/package.json +++ b/apps/bot/package.json @@ -18,51 +18,51 @@ "node": ">=v18.16.1" }, "dependencies": { - "@discordjs/collection": "^1.5.2", + "@discordjs/collection": "^2.0.0", "@lavaclient/spotify": "^3.1.0", "@lavalink/encoding": "^0.1.2", "@master-bot/api": "^0.1.0", - "@napi-rs/canvas": "^0.1.41", - "@prisma/client": "^5.1.1", + "@napi-rs/canvas": "^0.1.44", + "@prisma/client": "^5.6.0", "@sapphire/decorators": "^6.0.2", - "@sapphire/discord.js-utilities": "^7.0.1", - "@sapphire/framework": "^4.5.1", - "@sapphire/plugin-hmr": "^2.0.1", + "@sapphire/discord.js-utilities": "^7.1.2", + "@sapphire/framework": "^4.8.2", + "@sapphire/plugin-hmr": "^2.0.3", "@sapphire/time-utilities": "^1.7.10", "@sapphire/utilities": "^3.13.0", - "@t3-oss/env-core": "^0.6.0", - "@trpc/client": "^10.37.1", - "@trpc/server": "^10.37.1", - "axios": "^1.4.0", + "@t3-oss/env-core": "^0.7.1", + "@trpc/client": "^10.43.7", + "@trpc/server": "^10.43.7", + "axios": "^1.6.2", "colorette": "^2.0.20", - "discord.js": "^14.12.1", + "discord.js": "^14.14.1", "genius-discord-lyrics": "1.0.5", "google-translate-api-x": "^10.6.7", "ioredis": "^5.3.2", - "iso-639-1": "^2.1.15", + "iso-639-1": "^3.1.0", "lavaclient": "^4.1.1", "metadata-filter": "^1.3.0", "ncp": "^2.0.0", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", "string-progressbar": "^1.0.4", - "superjson": "1.13.1", - "winston": "^3.10.0", + "superjson": "1.13.3", + "winston": "^3.11.0", "winston-daily-rotate-file": "^4.7.1", - "zod": "^3.21.4" + "zod": "^3.22.4" }, "devDependencies": { "@lavaclient/types": "^2.1.1", - "@sapphire/ts-config": "^4.0.1", + "@sapphire/ts-config": "^5.0.0", "@types/ioredis": "^4.28.10", - "@types/node": "^20.4.6", - "@typescript-eslint/eslint-plugin": "^6.2.1", - "@typescript-eslint/parser": "^6.2.1", + "@types/node": "^20.9.3", + "@typescript-eslint/eslint-plugin": "^6.12.0", + "@typescript-eslint/parser": "^6.12.0", "dotenv": "^16.3.1", - "dotenv-cli": "^7.2.1", - "prettier": "^3.0.1", - "tslib": "^2.6.1", - "typescript": "^5.1.6" + "dotenv-cli": "^7.3.0", + "prettier": "^3.1.0", + "tslib": "^2.6.2", + "typescript": "^5.3.2" }, "eslintConfig": { "root": true, diff --git a/apps/bot/src/lib/music/buttonsCollector.ts b/apps/bot/src/lib/music/buttonsCollector.ts index 4ff232a8b..408b7baa5 100644 --- a/apps/bot/src/lib/music/buttonsCollector.ts +++ b/apps/bot/src/lib/music/buttonsCollector.ts @@ -16,7 +16,7 @@ export default async function buttonsCollector(message: Message, song: Song) { if (!channel) return; const maxLimit = Time.Minute * 30; - let timer: NodeJS.Timer; + let timer; collector.on('collect', async (i: MessageComponentInteraction) => { if (!message.member?.voice.channel?.members.has(i.user.id)) { diff --git a/apps/bot/src/lib/structures/ExtendedClient.ts b/apps/bot/src/lib/structures/ExtendedClient.ts index 7d65f768f..7fb89d0a5 100644 --- a/apps/bot/src/lib/structures/ExtendedClient.ts +++ b/apps/bot/src/lib/structures/ExtendedClient.ts @@ -7,7 +7,7 @@ import { deletePlayerEmbed } from '../music/buttonsCollector'; export class ExtendedClient extends SapphireClient { readonly music: QueueClient; - leaveTimers: { [key: string]: NodeJS.Timer }; + leaveTimers: { [key: string]: NodeJS.Timeout }; public constructor() { super({ intents: [ @@ -65,7 +65,7 @@ export class ExtendedClient extends SapphireClient { declare module '@sapphire/framework' { interface SapphireClient { readonly music: QueueClient; - leaveTimers: { [key: string]: NodeJS.Timer }; + leaveTimers: { [key: string]: NodeJS.Timeout }; } } diff --git a/apps/dashboard/next.config.mjs b/apps/dashboard/next.config.mjs index b297594cb..a793ff12c 100644 --- a/apps/dashboard/next.config.mjs +++ b/apps/dashboard/next.config.mjs @@ -12,9 +12,6 @@ const config = { typescript: { ignoreBuildErrors: true }, images: { domains: ['cdn.discordapp.com'] - }, - experimental: { - serverActions: true } }; diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index a45ba7ae2..7d17563bf 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -16,44 +16,44 @@ "@master-bot/api": "^0.1.0", "@master-bot/auth": "^0.1.0", "@master-bot/db": "^0.1.0", - "@radix-ui/react-dropdown-menu": "^2.0.5", - "@radix-ui/react-select": "^1.2.2", + "@radix-ui/react-dropdown-menu": "^2.0.6", + "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-switch": "^1.0.3", - "@radix-ui/react-toast": "^1.1.4", - "@t3-oss/env-nextjs": "^0.6.0", - "@tanstack/react-query": "^4.32.1", - "@tanstack/react-query-devtools": "^4.32.1", - "@tanstack/react-query-next-experimental": "5.0.0-alpha.80", - "@trpc/client": "^10.37.1", - "@trpc/next": "^10.37.1", - "@trpc/react-query": "^10.37.1", - "@trpc/server": "^10.37.1", + "@radix-ui/react-toast": "^1.1.5", + "@t3-oss/env-nextjs": "^0.7.1", + "@tanstack/react-query": "^5.8.4", + "@tanstack/react-query-devtools": "^5.8.4", + "@tanstack/react-query-next-experimental": "5.8.4", + "@trpc/client": "^10.43.7", + "@trpc/next": "^10.43.7", + "@trpc/react-query": "^10.43.7", + "@trpc/server": "^10.43.7", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", - "discord-api-types": "^0.37.51", - "lucide-react": "^0.263.1", - "next": "^13.4.12", + "discord-api-types": "^0.37.64", + "lucide-react": "^0.292.0", + "next": "^14.0.3", "next-themes": "^0.2.1", "react": "18.2.0", "react-dom": "18.2.0", - "superjson": "1.13.1", - "tailwind-merge": "^1.14.0", - "tailwindcss-animate": "^1.0.6", - "zod": "^3.21.4" + "superjson": "1.13.3", + "tailwind-merge": "^2.0.0", + "tailwindcss-animate": "^1.0.7", + "zod": "^3.22.4" }, "devDependencies": { "@master-bot/eslint-config": "^0.2.0", "@master-bot/tailwind-config": "^0.1.0", - "@types/node": "^20.4.6", - "@types/react": "^18.2.18", - "@types/react-dom": "^18.2.7", - "autoprefixer": "^10.4.14", - "dotenv-cli": "^7.2.1", - "eslint": "^8.46.0", - "postcss": "^8.4.27", - "tailwindcss": "^3.3.3", - "typescript": "^5.1.6" + "@types/node": "^20.9.3", + "@types/react": "^18.2.38", + "@types/react-dom": "^18.2.16", + "autoprefixer": "^10.4.16", + "dotenv-cli": "^7.3.0", + "eslint": "^8.54.0", + "postcss": "^8.4.31", + "tailwindcss": "^3.3.5", + "typescript": "^5.3.2" }, "eslintConfig": { "root": true, diff --git a/apps/dashboard/src/app/api/trpc/[trpc]/route.ts b/apps/dashboard/src/app/api/trpc/[trpc]/route.ts index 5deba894d..e2997e5d8 100644 --- a/apps/dashboard/src/app/api/trpc/[trpc]/route.ts +++ b/apps/dashboard/src/app/api/trpc/[trpc]/route.ts @@ -1,38 +1,12 @@ -import { appRouter, createTRPCContext } from '@master-bot/api'; import { fetchRequestHandler } from '@trpc/server/adapters/fetch'; -import { auth } from '@master-bot/auth'; - -export const runtime = 'nodejs'; - -/** - * Configure basic CORS headers - * You should extend this to match your needs - */ -function setCorsHeaders(res: Response) { - res.headers.set('Access-Control-Allow-Origin', '*'); - res.headers.set('Access-Control-Request-Method', '*'); - res.headers.set('Access-Control-Allow-Methods', 'OPTIONS, GET, POST'); - res.headers.set('Access-Control-Allow-Headers', '*'); -} - -export function OPTIONS() { - const response = new Response(null, { - status: 204 - }); - setCorsHeaders(response); - return response; -} +import { appRouter, createTRPCContext } from '@master-bot/api'; -const handler = auth(async req => { - const response = await fetchRequestHandler({ - endpoint: '/api/trpc', - router: appRouter, +const handler = (req: Request) => + fetchRequestHandler({ req, - createContext: () => createTRPCContext({ auth: req.auth, req }) + router: appRouter, + endpoint: '/api/trpc', + createContext: createTRPCContext }); - setCorsHeaders(response); - return response; -}); - export { handler as GET, handler as POST }; diff --git a/apps/dashboard/src/components/auth.tsx b/apps/dashboard/src/components/auth.tsx index b34fa3319..8eea5de12 100644 --- a/apps/dashboard/src/components/auth.tsx +++ b/apps/dashboard/src/components/auth.tsx @@ -1,6 +1,5 @@ import type { ComponentProps } from 'react'; import type { OAuthProviders } from '@master-bot/auth'; -import { CSRF_experimental } from '@master-bot/auth'; export function SignIn({ provider, @@ -9,7 +8,6 @@ export function SignIn({ return (