refactor: replace TypeORM with knex.js

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2025-03-14 23:33:29 +01:00
parent 6e151c8a1b
commit 4bd49085c6
No known key found for this signature in database
GPG key ID: DB99ADDDC5C0AF82
241 changed files with 4577 additions and 6636 deletions

View file

@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2025 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { isArray } from 'class-validator';
import { FieldNameNote, Note } from '../../database/types';
import { NoteService } from '../../notes/note.service';
import { CompleteRequest } from './request.type';
export async function extractNoteIdFromRequest(
request: CompleteRequest,
noteService: NoteService,
): Promise<Note[FieldNameNote.id] | undefined> {
const alias = extractNoteAlias(request);
if (alias === undefined) {
return undefined;
}
return await noteService.getNoteIdByAlias(alias);
}
function extractNoteAlias(request: CompleteRequest): string | undefined {
const noteAlias =
request.params['noteAlias'] || request.headers['hedgedoc-note'];
if (isArray(noteAlias)) {
return noteAlias[0];
}
return noteAlias;
}