adjust args

This commit is contained in:
Emily
2024-06-27 19:32:28 +02:00
parent f675e1f289
commit b7ae183c47
5 changed files with 62 additions and 24 deletions

View File

@@ -47,4 +47,5 @@ LICENSE
readme.md
SECURITY.md
steps
docker-compose.yml
docker-compose.yml
docker-compose.admin.yml

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
steps
PROCESS_EVENT
docker
dev
dev
docker-compose.admin.yml

View File

@@ -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

View File

@@ -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;
});

View File

@@ -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: