From 878006271f889df66f90ead9559703e0f562c983 Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Fri, 10 Feb 2023 12:22:36 +0100 Subject: [PATCH] Prettier fixes --- src/common/logger.ts | 2 +- src/common/reservation.ts | 5 ++++- src/server/http/routes/cron.ts | 8 ++++---- src/server/http/routes/index.ts | 26 ++++++++++++++------------ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/common/logger.ts b/src/common/logger.ts index 792cc89..356a954 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -90,4 +90,4 @@ export class LoggableError extends Error { toString() { return `${this.name} - ${this.message}\n${this.stack}` } -} \ No newline at end of file +} diff --git a/src/common/reservation.ts b/src/common/reservation.ts index 2197e31..9b38367 100644 --- a/src/common/reservation.ts +++ b/src/common/reservation.ts @@ -286,7 +286,10 @@ export class Reservation { return [] } - public static async fetchByPage(pageNumber: number, pageSize = 50): Promise { + public static async fetchByPage( + pageNumber: number, + pageSize = 50 + ): Promise { const response = await all( ` SELECT * diff --git a/src/server/http/routes/cron.ts b/src/server/http/routes/cron.ts index ad4957f..bada3f6 100644 --- a/src/server/http/routes/cron.ts +++ b/src/server/http/routes/cron.ts @@ -6,7 +6,7 @@ import { getStatus, startTasks, stopTasks } from '../../cron' export class CronRouter extends Router { public async handleRequest( req: IncomingMessage, - res: ServerResponse, + res: ServerResponse ) { const { url = '', method } = req const [route] = url.split('?') @@ -31,7 +31,7 @@ export class CronRouter extends Router { private async GET_cron( _req: IncomingMessage, - res: ServerResponse, + res: ServerResponse ) { l.getStore()?.debug('Checking cron status') const status = getStatus() @@ -43,7 +43,7 @@ export class CronRouter extends Router { private async POST_cron_enable( _req: IncomingMessage, - res: ServerResponse, + res: ServerResponse ) { l.getStore()?.debug('Enabling cron') startTasks() @@ -52,7 +52,7 @@ export class CronRouter extends Router { private async POST_cron_disable( _req: IncomingMessage, - res: ServerResponse, + res: ServerResponse ) { l.getStore()?.debug('Disabling cron') stopTasks() diff --git a/src/server/http/routes/index.ts b/src/server/http/routes/index.ts index aef973c..f467170 100644 --- a/src/server/http/routes/index.ts +++ b/src/server/http/routes/index.ts @@ -1,23 +1,22 @@ import { IncomingMessage, ServerResponse } from 'http' -import { asyncLocalStorage, asyncLocalStorage as l, LoggableError } from '../../../common/logger' +import { + asyncLocalStorage, + asyncLocalStorage as l, + LoggableError, +} from '../../../common/logger' import { parseJson } from '../../utils' export abstract class Router { - protected async parseJsonContent( - req: IncomingMessage, - ) { + protected async parseJsonContent(req: IncomingMessage) { let jsonBody: Record - const contentType = - req.headers['content-type'] || 'application/json' + const contentType = req.headers['content-type'] || 'application/json' if (contentType !== 'application/json') { l.getStore()?.error('Invalid content type', { contentType }) throw new RouterUnsupportedContentTypeError() } try { - const length = Number.parseInt( - req.headers['content-length'] || '0' - ) + const length = Number.parseInt(req.headers['content-length'] || '0') const encoding = req.readableEncoding || 'utf8' jsonBody = await parseJson(length, encoding, req) } catch (error: unknown) { @@ -31,7 +30,10 @@ export abstract class Router { return jsonBody } - protected handle404(req: IncomingMessage, res: ServerResponse) { + protected handle404( + req: IncomingMessage, + res: ServerResponse + ) { const { url, method } = req asyncLocalStorage.getStore()?.info('Not found', { url, method }) res.writeHead(404, 'Not found') @@ -39,10 +41,10 @@ export abstract class Router { public abstract handleRequest( req: IncomingMessage, - res: ServerResponse, + res: ServerResponse ): Promise } export class RouterError extends LoggableError {} export class RouterBadRequestError extends RouterError {} -export class RouterUnsupportedContentTypeError extends RouterError {} \ No newline at end of file +export class RouterUnsupportedContentTypeError extends RouterError {}