Skip to content

Commit

Permalink
Merge pull request #133 from letehaha/fix/issues
Browse files Browse the repository at this point in the history
fix: Minor issues
  • Loading branch information
letehaha authored Sep 16, 2024
2 parents 45fb4d8 + 1f16e0b commit c3d86e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions docker/test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions src/controllers/categories.controller/create-category.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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),
Expand All @@ -41,7 +41,7 @@ export const CreateCategoryPayloadSchema = z
color: z
.string()
.regex(/^#[0-9A-F]{6}$/i)
.optional(),
.nullish(),
}),
z.object({
parentId: z.undefined(),
Expand All @@ -53,3 +53,5 @@ export const CreateCategoryPayloadSchema = z
export const createCategorySchema = z.object({
body: CreateCategoryPayloadSchema,
});

type CreateCategoryParams = z.infer<typeof CreateCategoryPayloadSchema>;

0 comments on commit c3d86e7

Please sign in to comment.