diff --git a/compose.yaml b/compose.yaml index 7508d15..0a12f32 100644 --- a/compose.yaml +++ b/compose.yaml @@ -14,7 +14,7 @@ services: - DATABASE_URL=postgresql://your_username:your_password@10.0.27.1:5432/epess - CLERK_PUBLISHABLE_KEY=pk_test_aW4tY2hpbXAtOTcuY2xlcmsuYWNjb3VudHMuZGV2JA - CLERK_SECRET_KEY=sk_test_sA5lsb1GHwUNXWQCp5ev70QkaoF5EmdAHNWiCGwZF6 - - CORS_ORIGIN=http://localhost:3000 + - CORS_ORIGIN=https://epess.org,https://admin.epess.org,https://center.epess.org,http://localhost:3000,http://localhost:3069,http://localhost:3001 - LISTEN_PORT=3069 - SWAGGER_PATH=/v1 labels: diff --git a/package-lock.json b/package-lock.json index cf20f3f..5785ed6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "UNLICENSED", "dependencies": { "@apollo/server": "^4.11.0", - "@clerk/clerk-sdk-node": "^5.0.45", + "@clerk/express": "^1.2.2", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/introspection": "^4.0.3", "@graphql-codegen/typescript": "^4.0.9", @@ -1827,19 +1827,22 @@ "node": ">=18.17.0" } }, - "node_modules/@clerk/clerk-sdk-node": { - "version": "5.0.49", - "resolved": "https://registry.npmjs.org/@clerk/clerk-sdk-node/-/clerk-sdk-node-5.0.49.tgz", - "integrity": "sha512-1MmXcqYIgifya6ISQw34Fv3E+xHaCvdD1d97efUJvytEvE6oMdQpP1sLyzkhfcb1RXk7T7y7OGZggQbirP3JXQ==", + "node_modules/@clerk/express": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@clerk/express/-/express-1.2.2.tgz", + "integrity": "sha512-rI+jKVDmp9KUSHW04ZVUsrG4oP652AgYczyFCF0r1/2bEgpxxtUmZt5W2M4xyBV4hn9a649ic2NlChcKFqve2A==", "license": "MIT", "dependencies": { - "@clerk/backend": "1.13.9", - "@clerk/shared": "2.9.0", + "@clerk/backend": "^1.13.9", + "@clerk/shared": "^2.9.0", "@clerk/types": "4.25.0", "tslib": "2.4.1" }, "engines": { "node": ">=18.17.0" + }, + "peerDependencies": { + "express": "^4.17.0 || ^5.0.0" } }, "node_modules/@clerk/shared": { diff --git a/package.json b/package.json index 4014894..1bd4656 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "dependencies": { "@apollo/server": "^4.11.0", - "@clerk/clerk-sdk-node": "^5.0.45", + "@clerk/express": "^1.2.2", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/introspection": "^4.0.3", "@graphql-codegen/typescript": "^4.0.9", diff --git a/src/Clerk/clerk-auth.guard.ts b/src/Clerk/clerk-auth.guard.ts index 79bf88e..ca66c85 100644 --- a/src/Clerk/clerk-auth.guard.ts +++ b/src/Clerk/clerk-auth.guard.ts @@ -6,7 +6,7 @@ import { Inject, UnauthorizedException, } from '@nestjs/common'; -import Clerk from '@clerk/clerk-sdk-node'; +import Clerk from '@clerk/express'; import { GqlExecutionContext } from '@nestjs/graphql'; @Injectable() diff --git a/src/Clerk/clerk.module.ts b/src/Clerk/clerk.module.ts index cd8a248..fb77d9c 100644 --- a/src/Clerk/clerk.module.ts +++ b/src/Clerk/clerk.module.ts @@ -1,5 +1,5 @@ import { Module, Global } from '@nestjs/common'; -import Clerk from '@clerk/clerk-sdk-node'; +import Clerk from '@clerk/express'; import { ClerkService } from './clerk.service'; import ClerkController from './clerk.controller'; @Global() diff --git a/src/User/user.schema.ts b/src/User/user.schema.ts index 05cacf6..d02261f 100644 --- a/src/User/user.schema.ts +++ b/src/User/user.schema.ts @@ -7,8 +7,7 @@ import { } from '@smatch-corp/nestjs-pothos'; import { Builder } from '../Graphql/graphql.builder'; import { PrismaService } from '../Prisma/prisma.service'; -import { clerkClient } from '@clerk/clerk-sdk-node'; - +import { clerkClient } from '@clerk/express'; @Injectable() export class UserSchema extends PothosSchema { constructor( diff --git a/src/main.ts b/src/main.ts index 23b54cb..c50cbff 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,8 +4,10 @@ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; async function bootstrap() { const app = await NestFactory.create(AppModule); + + const corsOrigin = (process.env.CORS_ORIGIN ?? '').split(','); // split by comma to array app.enableCors({ - origin: process.env.CORS_ORIGIN, + origin: corsOrigin, methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization'], credentials: true,