From 5264c3316918a12bb115f94776db87d1d663249c Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Mon, 16 Sep 2024 18:59:14 +0200 Subject: [PATCH 1/2] fix: Remove ports exposing from test/docker-compose to not conflict with dev containers --- docker/test/docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/test/docker-compose.yml b/docker/test/docker-compose.yml index 066c5c6..e9ccb4e 100644 --- a/docker/test/docker-compose.yml +++ b/docker/test/docker-compose.yml @@ -8,14 +8,12 @@ services: - POSTGRES_USER=${APPLICATION_DB_USERNAME} - POSTGRES_PASSWORD=${APPLICATION_DB_PASSWORD} - POSTGRES_DB=${APPLICATION_DB_DATABASE} - ports: ['${APPLICATION_DB_PORT}:5432'] env_file: ../../.env.test test-redis: image: redis:6 container_name: test-budget-tracker-redis volumes: ['test_redis_data:/data'] - ports: ['6379:6379'] test-runner: build: From 1f16e0be50dcc929c5a4eaae63fc9d1429e2abfc Mon Sep 17 00:00:00 2001 From: Dmytro Svyrydenko Date: Mon, 16 Sep 2024 18:59:26 +0200 Subject: [PATCH 2/2] fix: Categories creation --- .../categories.controller/create-category.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/controllers/categories.controller/create-category.ts b/src/controllers/categories.controller/create-category.ts index 5e55bcf..9ebc2c1 100644 --- a/src/controllers/categories.controller/create-category.ts +++ b/src/controllers/categories.controller/create-category.ts @@ -1,12 +1,12 @@ import { z } from 'zod'; -import { API_RESPONSE_STATUS, CATEGORY_TYPES, endpointsTypes } from 'shared-types'; +import { API_RESPONSE_STATUS, CATEGORY_TYPES } from 'shared-types'; import { CustomResponse } from '@common/types'; import * as categoriesService from '@root/services/categories/create-category'; import { errorHandler } from '../helpers'; export const createCategory = async (req, res: CustomResponse) => { const { id: userId } = req.user; - const { name, imageUrl, color, parentId }: endpointsTypes.CreateCategoryBody = req.validated.body; + const { name, imageUrl, color, parentId }: CreateCategoryParams = req.validated.body; try { const data = await categoriesService.createCategory({ @@ -29,7 +29,7 @@ export const createCategory = async (req, res: CustomResponse) => { export const CreateCategoryPayloadSchema = z .object({ name: z.string().min(1).max(200, 'The name must not exceed 200 characters'), - imageUrl: z.string().url().max(500, 'The URL must not exceed 500 characters').optional(), + imageUrl: z.string().url().max(500, 'The URL must not exceed 500 characters').nullish(), type: z .enum(Object.values(CATEGORY_TYPES) as [string, ...string[]]) .default(CATEGORY_TYPES.custom), @@ -41,7 +41,7 @@ export const CreateCategoryPayloadSchema = z color: z .string() .regex(/^#[0-9A-F]{6}$/i) - .optional(), + .nullish(), }), z.object({ parentId: z.undefined(), @@ -53,3 +53,5 @@ export const CreateCategoryPayloadSchema = z export const createCategorySchema = z.object({ body: CreateCategoryPayloadSchema, }); + +type CreateCategoryParams = z.infer;