Skip to content

Commit

Permalink
feat: refactor type for seed
Browse files Browse the repository at this point in the history
  • Loading branch information
wielopolski committed Nov 6, 2024
1 parent c39c030 commit d7537e7
Show file tree
Hide file tree
Showing 10 changed files with 664 additions and 299 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/deploy-api-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,11 @@ jobs:
ECS_CLUSTER: ${{ secrets.AWS_ECS_CLUSTER }}
ECS_SERVICE: ${{ secrets.AWS_ECS_SERVICE }}
DOCKER_IMAGE: ${{ secrets.AWS_ECR_REGISTRY }}:${{ github.sha }}
run: selleo aws ecs deploy --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --docker-image $DOCKER_IMAGE --one-off migrate --one-off seed
run: selleo aws ecs deploy --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --docker-image $DOCKER_IMAGE --one-off migrate --one-off storage/seed/seed.production

- name: ECS Run migrations
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
ECS_CLUSTER: ${{ secrets.AWS_ECS_CLUSTER }}
ECS_SERVICE: ${{ secrets.AWS_ECS_SERVICE }}
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off migrate

- name: ECS Run seeds
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
ECS_CLUSTER: ${{ secrets.AWS_ECS_CLUSTER }}
ECS_SERVICE: ${{ secrets.AWS_ECS_SERVICE }}
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off seed
4 changes: 2 additions & 2 deletions .github/workflows/deploy-api-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
ECS_CLUSTER: ${{ vars.AWS_ECS_CLUSTER }}
ECS_SERVICE: ${{ vars.AWS_ECS_SERVICE }}
DOCKER_IMAGE: ${{ secrets.AWS_ECR_REGISTRY }}:${{ github.sha }}
run: selleo aws ecs deploy --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --docker-image $DOCKER_IMAGE --one-off migrate --one-off seed
run: selleo aws ecs deploy --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --docker-image $DOCKER_IMAGE --one-off migrate --one-off storage/seed/seed

- name: ECS Run migrations
env:
Expand All @@ -70,4 +70,4 @@ jobs:
AWS_REGION: ${{ vars.AWS_REGION }}
ECS_CLUSTER: ${{ vars.AWS_ECS_CLUSTER }}
ECS_SERVICE: ${{ vars.AWS_ECS_SERVICE }}
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off seed
run: selleo aws ecs run --region $AWS_REGION --cluster $ECS_CLUSTER --service $ECS_SERVICE --one-off storage/seed/seed
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:e2e:watch": "jest --config ./test/jest-e2e.json --watch",
"db:migrate": "drizzle-kit migrate",
"db:generate": "drizzle-kit generate",
"db:seed": "ts-node -r tsconfig-paths/register ./src/seed.ts",
"db:seed": "ts-node -r tsconfig-paths/register ./src/storage/seed/seed.ts",
"db:seed-prod": "node dist/src/seed.js"
},
"dependencies": {
Expand Down
10 changes: 8 additions & 2 deletions apps/api/src/courses/schemas/createCourse.schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Static, Type } from "@sinclair/typebox";
import { STATES } from "src/common/states";

export const createCourseSchema = Type.Object({
export const baseCourseSchema = Type.Object({
title: Type.String(),
description: Type.String(),
state: Type.Union([
Expand All @@ -12,7 +12,13 @@ export const createCourseSchema = Type.Object({
priceInCents: Type.Integer(),
currency: Type.Optional(Type.String()),
categoryId: Type.String({ format: "uuid" }),
lessons: Type.Optional(Type.Array(Type.String({ format: "uuid" }))),
});

export const createCourseSchema = Type.Intersect([
baseCourseSchema,
Type.Object({
lessons: Type.Optional(Type.Array(Type.String({ format: "uuid" }))),
}),
]);

export type CreateCourseBody = Static<typeof createCourseSchema>;
175 changes: 0 additions & 175 deletions apps/api/src/nice-data-seeds.ts

This file was deleted.

Loading

0 comments on commit d7537e7

Please sign in to comment.