diff --git a/api/src/models/container.model.ts b/api/src/models/container.model.ts index 202b6ab..732ec23 100644 --- a/api/src/models/container.model.ts +++ b/api/src/models/container.model.ts @@ -19,7 +19,7 @@ import { Page } from '.'; @Table({ paranoid: true }) -export default class Container extends Model { +export default class Container extends Model { @PrimaryKey @AutoIncrement @Column(DataType.INTEGER) @@ -73,7 +73,7 @@ export default class Container extends Model { page.changed('updatedAt', true); - return await page.save(); + await page.save().then(() => {}); }); } } diff --git a/api/src/models/page.model.ts b/api/src/models/page.model.ts index bcda96f..6b2db64 100644 --- a/api/src/models/page.model.ts +++ b/api/src/models/page.model.ts @@ -19,7 +19,7 @@ import { Container } from '.'; @Table({ paranoid: true }) -export default class Page extends Model { +export default class Page extends Model { @PrimaryKey @Column(DataType.TEXT) public slug: string; diff --git a/api/src/utils/UploadService.ts b/api/src/utils/UploadService.ts index ba91d25..8b7729e 100644 --- a/api/src/utils/UploadService.ts +++ b/api/src/utils/UploadService.ts @@ -33,9 +33,9 @@ export class UploadService { } public saveFile (buffer: Buffer, mimeType: string): string { - if (!UploadService.MINE_TYPES.has(mimeType.toLowerCase())) throw new Error(`MIME type '${mimeType}' is not allowed`); + const fileEnding = UploadService.MINE_TYPES.get(mimeType.toLowerCase()); - const fileEnding: string = UploadService.MINE_TYPES.get(mimeType.toLowerCase()); + if (fileEnding === undefined) throw new Error(`MIME type '${mimeType}' is not allowed`); // generate random name let name = UploadService.randomName(); diff --git a/api/src/utils/sitemap.ts b/api/src/utils/sitemap.ts index c12f37a..d7eb8c1 100644 --- a/api/src/utils/sitemap.ts +++ b/api/src/utils/sitemap.ts @@ -3,7 +3,7 @@ import { SitemapStream, streamToPromise } from 'sitemap'; import { createGzip } from 'zlib'; import { Page } from '../models'; -let cachedSitemap: Buffer | null = null; +let cachedSitemap: Buffer; const BUILD_TIME_PATH = '/build-date.txt'; let buildTime = new Date(0); diff --git a/api/src/v1/routes/upload.router.ts b/api/src/v1/routes/upload.router.ts index c56a6f1..952f6cd 100644 --- a/api/src/v1/routes/upload.router.ts +++ b/api/src/v1/routes/upload.router.ts @@ -15,7 +15,7 @@ uploadRouter.post('/', [ ], wrapAsync(async (req, res) => { res.setHeader('Accept', UploadService.ALLOWED_MIME_TYPES.join(', ')); - const contentTypeHeader = req.get('Content-Type'); + const contentTypeHeader = req.get('Content-Type') ?? ''; const mime = contentTypeHeader.toLowerCase(); if (!UploadService.ALLOWED_MIME_TYPES.includes(mime)) {