Skip to content

Commit

Permalink
Merge pull request #81 from codex-team/fix/patch-note-settings
Browse files Browse the repository at this point in the history
fix: fixed note settings patch
  • Loading branch information
slaveeks authored Oct 21, 2023
2 parents dd845f3 + 17ffa3e commit 50b32fe
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/presentation/http/router/noteSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ import type NoteSettings from '@domain/entities/noteSettings.js';
import notEmpty from '@infrastructure/utils/notEmpty.js';
import useNoteResolver from '../middlewares/note/useNoteResolver.js';
import type NoteService from '@domain/service/note.js';

/**
* Get note by id options
*/
interface GetNoteSettingsByNodeIdOptions {
/**
* Note internal id
*/
id: NoteInternalId;
}
import { NotePublicId } from '@domain/entities/note.js';

/**
* Interface for the note settings router.
Expand Down Expand Up @@ -55,9 +46,11 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
* Returns Note settings by note id. Note public id is passed in route params, and it converted to internal id via middleware
*/
fastify.get<{
Params: GetNoteSettingsByNodeIdOptions,
Params: {
notePublicId: NotePublicId;
},
Reply: NoteSettings
}>('/:id', {
}>('/:notePublicId', {
preHandler: [
noteIdResolver,
],
Expand All @@ -67,7 +60,6 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
*/
const noteId = request.noteId as number;


const noteSettings = await noteSettingsService.getNoteSettingsByNoteId(noteId);

/**
Expand All @@ -85,9 +77,11 @@ const NoteSettingsRouter: FastifyPluginCallback<NoteSettingsRouterOptions> = (fa
*/
fastify.patch<{
Body: Partial<NoteSettings>,
Params: GetNoteSettingsByNodeIdOptions,
Params: {
notePublicId: NotePublicId;
},
Reply: NoteSettings,
}>('/:id', {
}>('/:notePublicId', {
config: {
policy: [
'authRequired',
Expand Down

0 comments on commit 50b32fe

Please sign in to comment.