diff --git a/.dockerignore b/.dockerignore index 9a46d6a..b947f56 100644 --- a/.dockerignore +++ b/.dockerignore @@ -47,4 +47,5 @@ LICENSE readme.md SECURITY.md steps -docker-compose.yml \ No newline at end of file +docker-compose.yml +docker-compose.admin.yml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 84493dd..17c3012 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ steps PROCESS_EVENT docker -dev \ No newline at end of file +dev +docker-compose.admin.yml \ No newline at end of file diff --git a/dashboard/Dockerfile b/dashboard/Dockerfile index f6a3712..880a000 100644 --- a/dashboard/Dockerfile +++ b/dashboard/Dockerfile @@ -17,6 +17,9 @@ COPY --link dashboard/ ./ COPY --link shared/ /home/shared +ARG GOOGLE_AUTH_CLIENT_ID +ENV GOOGLE_AUTH_CLIENT_ID=$GOOGLE_AUTH_CLIENT_ID + RUN npm run build RUN npm prune diff --git a/dashboard/server/api/project/create.post.ts b/dashboard/server/api/project/create.post.ts index a558805..75ab197 100644 --- a/dashboard/server/api/project/create.post.ts +++ b/dashboard/server/api/project/create.post.ts @@ -22,28 +22,56 @@ export default defineEventHandler(async event => { const existingUserProjects = await ProjectModel.countDocuments({ owner: userData.id }); if (existingUserProjects >= maxProjects) return setResponseStatus(event, 400, 'Already have max number of projects'); - const customer = await StripeService.createCustomer(userData.user.email); - if (!customer) return setResponseStatus(event, 400, 'Error creating customer'); + if (StripeService.isDisabled()) { - const subscription = await StripeService.createFreeSubscription(customer.id); - if (!subscription) return setResponseStatus(event, 400, 'Error creating subscription'); + const project = await ProjectModel.create({ + owner: userData.id, + name: newProjectName, + premium: false, + premium_type: 0, + customer_id: 'DISABLED_MODE', + subscription_id: "DISABLED_MODE", + premium_expire_at: new Date(3000, 1, 1) + }); - const project = await ProjectModel.create({ - owner: userData.id, - name: newProjectName, - premium: false, - premium_type: 0, - customer_id: customer.id, - subscription_id: subscription.id, - premium_expire_at: subscription.current_period_end * 1000 - }); - await ProjectCountModel.create({ - project_id: project._id, - events: 0, - visits: 0 - }); + await ProjectCountModel.create({ + project_id: project._id, + events: 0, + visits: 0 + }); + + return project.toJSON() as TProject; + + } else { + + const customer = await StripeService.createCustomer(userData.user.email); + if (!customer) return setResponseStatus(event, 400, 'Error creating customer'); + + const subscription = await StripeService.createFreeSubscription(customer.id); + if (!subscription) return setResponseStatus(event, 400, 'Error creating subscription'); + + const project = await ProjectModel.create({ + owner: userData.id, + name: newProjectName, + premium: false, + premium_type: 0, + customer_id: customer.id, + subscription_id: subscription.id, + premium_expire_at: subscription.current_period_end * 1000 + }); + + + await ProjectCountModel.create({ + project_id: project._id, + events: 0, + visits: 0 + }); + + return project.toJSON() as TProject; + + } + - return project.toJSON() as TProject; }); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0a046b0..ff199f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -86,9 +86,9 @@ services: # Optional - Used to register / login - - # NUXT_GOOGLE_AUTH_CLIENT_ID: "" - # NUXT_GOOGLE_AUTH_CLIENT_SECRET: "" + + NUXT_GOOGLE_AUTH_CLIENT_ID: "" + NUXT_GOOGLE_AUTH_CLIENT_SECRET: "" # Optional - Used for tests @@ -104,6 +104,11 @@ services: build: dockerfile: ./dashboard/Dockerfile + args: + + # Optional - Used to register / login + + GOOGLE_AUTH_CLIENT_ID: "" volumes: mongo-data: