Skip to content

Commit

Permalink
Update noteList.ts
Browse files Browse the repository at this point in the history
Delete nterface GetNoteListById in notelist router
  • Loading branch information
HyTekCoop committed Oct 19, 2023
1 parent a7d7d84 commit 33d0845
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/presentation/http/router/noteList.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import type { FastifyPluginCallback } from 'fastify';
import type NoteListService from '@domain/service/noteList';
import type { Middlewares } from '@presentation/http/middlewares/index.js';
import type { NoteCreatorId } from '@domain/entities/note';
import type { ErrorResponse } from '@presentation/http/types/HttpResponse';
import { StatusCodes } from 'http-status-codes';
import type { NoteList } from '@domain/entities/noteList';


interface GetNoteListById {
/**
* Note id
*/
id: NoteCreatorId;
};

/**
* Interface for the noteList router.
*/
interface NoteListRouterOptions {
/**
* Note service instance
* Note list service instance
*/
noteListService: NoteListService,

Expand All @@ -31,7 +22,7 @@ interface NoteListRouterOptions {


/**
* Note router plugin
* Note list router plugin
*
* @param fastify - fastify instance
* @param opts - empty options
Expand All @@ -42,15 +33,15 @@ const NoteListRouter: FastifyPluginCallback<NoteListRouterOptions> = (fastify, o
const noteListService = opts.noteListService;

/**
* Get note by id
* Get note list by userId
*/
fastify.get<{ Params: GetNoteListById }>('/', { preHandler: [opts.middlewares.authRequired, opts.middlewares.withUser] }, async (request, reply) => {
fastify.get('/', { preHandler: [opts.middlewares.authRequired, opts.middlewares.withUser] }, async (request, reply) => {
const userId = request.ctx.auth.id;

const noteList = await noteListService.getNoteListByCreatorId(userId);

/**
* Check if noteList does not exist
* Check if note list does not exist
*/
if (!noteList) {
const response: ErrorResponse = {
Expand Down

0 comments on commit 33d0845

Please sign in to comment.