diff --git a/biome.json b/biome.json index 2f68ff74..ed33de55 100644 --- a/biome.json +++ b/biome.json @@ -5,6 +5,10 @@ "ignore": ["node_modules", "docs"], "maxSize": 5000000 }, + "formatter": { + "enabled": true, + "lineEnding": "crlf" + }, "vcs": { "enabled": true, "clientKind": "git", diff --git a/lerna.json b/lerna.json index 692d168b..6c448de4 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { - "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.30.11" -} \ No newline at end of file + "$schema": "node_modules/lerna/schemas/lerna-schema.json", + "version": "0.30.11" +} diff --git a/packages/tslua-base64/package.json b/packages/tslua-base64/package.json index 64b0a277..8413692d 100644 --- a/packages/tslua-base64/package.json +++ b/packages/tslua-base64/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-base64", "version": "0.30.11", "description": "Base64 library with typings", - "keywords": [ - "lua", - "dcs", - "base64" - ], + "keywords": ["lua", "dcs", "base64"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-common/package.json b/packages/tslua-common/package.json index 641af736..30c301b0 100644 --- a/packages/tslua-common/package.json +++ b/packages/tslua-common/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-common", "version": "0.30.11", "description": "Common Utils Library", - "keywords": [ - "lua", - "dcs", - "logger" - ], + "keywords": ["lua", "dcs", "logger"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-dcs-gui-types/package.json b/packages/tslua-dcs-gui-types/package.json index 2ca36f82..2545a2c8 100644 --- a/packages/tslua-dcs-gui-types/package.json +++ b/packages/tslua-dcs-gui-types/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-dcs-gui-types", "version": "0.30.11", "description": "Typescript type definitions for DCS GUI environment", - "keywords": [ - "lua", - "dcs", - "gui" - ], + "keywords": ["lua", "dcs", "gui"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-dcs-mission-types/package.json b/packages/tslua-dcs-mission-types/package.json index bdae3a99..c79c61df 100644 --- a/packages/tslua-dcs-mission-types/package.json +++ b/packages/tslua-dcs-mission-types/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-dcs-mission-types", "version": "0.30.11", "description": "Typescript type definitions for DCS", - "keywords": [ - "lua", - "dcs", - "mission" - ], + "keywords": ["lua", "dcs", "mission"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-http-api/package.json b/packages/tslua-http-api/package.json index e723a73a..34209f68 100644 --- a/packages/tslua-http-api/package.json +++ b/packages/tslua-http-api/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-http-api", "version": "0.30.11", "description": "LUA HTTP API Server written in Typescript Transpiled to lua using TypeScriptToLua", - "keywords": [ - "lua", - "http", - "api" - ], + "keywords": ["lua", "http", "api"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" @@ -27,9 +23,7 @@ }, "nodemonConfig": { "verbose": true, - "watch": [ - "dist" - ], + "watch": ["dist"], "ext": "lua", "exec": "npm run dev" }, diff --git a/packages/tslua-http-api/src/application.ts b/packages/tslua-http-api/src/application.ts index f5316eca..a8dc3506 100644 --- a/packages/tslua-http-api/src/application.ts +++ b/packages/tslua-http-api/src/application.ts @@ -63,6 +63,7 @@ export class AppHttpRequest { } constructor( + private readonly app: Application, public readonly req: HttpRequest, pathParams: Record, ) { @@ -129,7 +130,10 @@ export class AppHttpRequest { export class AppHttpResponse { protected logger = new Logger("AppHttpResponse"); - constructor(public readonly res: HttpResponse) {} + constructor( + private readonly app: Application, + public readonly res: HttpResponse, + ) {} /** * Sets the HTTP status code. @@ -167,8 +171,13 @@ export class AppHttpResponse { */ json(value: T): this { this.res.headers["Content-Type"] = "application/json"; - this.res.body = json.encode(value); - return this; + try { + this.res.body = json.encode(value); + return this; + } catch (e) { + this.app.errors.push({ error: e as Error, value }); + throw e; + } } /** @@ -202,6 +211,8 @@ export type AppErrorMiddleware = ( * A class representing a web application, extending the functionality of HttpServer. */ export class Application extends HttpServer { + public errors: { error: Error; [key: string]: any }[] = []; + protected requestHandlers: { route: string; method?: string; @@ -323,8 +334,8 @@ export class Application extends HttpServer { res.status = HttpStatus.OK; } - const appRequest = new AppHttpRequest(req, {}); - const appResponse = new AppHttpResponse(res); + const appRequest = new AppHttpRequest(this, req, {}); + const appResponse = new AppHttpResponse(this, res); try { const runStackItem = (idx: number) => { diff --git a/packages/tslua-http/package.json b/packages/tslua-http/package.json index fc972895..57be5bc5 100644 --- a/packages/tslua-http/package.json +++ b/packages/tslua-http/package.json @@ -2,10 +2,7 @@ "name": "@flying-dice/tslua-http", "version": "0.30.11", "description": "LUA HTTP Server written in Typescript Transpiled to lua using TypeScriptToLua", - "keywords": [ - "lua", - "http" - ], + "keywords": ["lua", "http"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-luatest/package.json b/packages/tslua-luatest/package.json index ae8b7502..1a405131 100644 --- a/packages/tslua-luatest/package.json +++ b/packages/tslua-luatest/package.json @@ -2,11 +2,7 @@ "name": "@flying-dice/tslua-luatest", "version": "0.30.11", "description": "tslua testing library", - "keywords": [ - "lua", - "dcs", - "test" - ], + "keywords": ["lua", "dcs", "test"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-openapi/package.json b/packages/tslua-openapi/package.json index 24b874b9..0bd0773d 100644 --- a/packages/tslua-openapi/package.json +++ b/packages/tslua-openapi/package.json @@ -2,12 +2,7 @@ "name": "@flying-dice/tslua-openapi", "version": "0.30.11", "description": "Re-export of https://github.com/metadevpro/openapi3-ts/ library for tslua", - "keywords": [ - "lua", - "http", - "api", - "openapi" - ], + "keywords": ["lua", "http", "api", "openapi"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/packages/tslua-rxi-json/package.json b/packages/tslua-rxi-json/package.json index 3dcc11cf..5467393d 100644 --- a/packages/tslua-rxi-json/package.json +++ b/packages/tslua-rxi-json/package.json @@ -4,12 +4,7 @@ "description": "rxi-json library with typings", "types": "./index.d.ts", "main": "./index", - "keywords": [ - "lua", - "dcs", - "json", - "rxi/json" - ], + "keywords": ["lua", "dcs", "json", "rxi/json"], "repository": { "type": "git", "url": "https://github.com/flying-dice/tslua-dcs.git" diff --git a/renovate.json b/renovate.json index 5db72dd6..ac084260 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,4 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:recommended" - ] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"] }