From 14f1283655726e179bfda9a400f6ab418c1bae65 Mon Sep 17 00:00:00 2001 From: Siddhi doshi Date: Tue, 15 Oct 2024 00:11:12 +0530 Subject: [PATCH 1/2] fix: linting issues --- libs/movex-server/src/lib/movex-server.ts | 12 ++++++------ libs/movex-server/tsconfig.json | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/movex-server/src/lib/movex-server.ts b/libs/movex-server/src/lib/movex-server.ts index 03c4e0ac..e03e7f5c 100644 --- a/libs/movex-server/src/lib/movex-server.ts +++ b/libs/movex-server/src/lib/movex-server.ts @@ -20,8 +20,8 @@ import { } from 'movex-master'; import { delay, isOneOf } from './util'; -const pkgVersion = require('../../package.json').version; - +import { version as pkgVersion } from '../../package.json'; +import { ResourceIdentifier } from 'movex-core-util'; const logsy = globalLogsy.withNamespace('[MovexServer]'); logsy.onLog((event) => { @@ -144,7 +144,9 @@ export const movexServer = ( // }); app.get('/api/resources/:rid', async (req, res) => { - const rawRid = req.params.rid; + const rawRid = req.params.rid as ResourceIdentifier< + Extract + >; if (!isResourceIdentifier(rawRid)) { return res.sendStatus(400); // Bad Request @@ -159,7 +161,7 @@ export const movexServer = ( res.header('Content-Type', 'application/json'); return store - .get(rawRid as any) // TODO: Not sure why this doesn't see it and needs to be casted to any? + .get(rawRid) .map((data) => { res.send(JSON.stringify(data, null, 4)); }) @@ -217,8 +219,6 @@ export const movexServer = ( // start the server const port = process.env['port'] || 3333; httpServer.listen(port, () => { - const address = httpServer.address(); - // console.log(`[movex-server] v${pkgVersion} started at port ${port}.`); // if (typeof address !== 'string') { diff --git a/libs/movex-server/tsconfig.json b/libs/movex-server/tsconfig.json index 2cac7b7d..09e3e4b0 100644 --- a/libs/movex-server/tsconfig.json +++ b/libs/movex-server/tsconfig.json @@ -9,5 +9,8 @@ { "path": "./tsconfig.spec.json" } - ] -} \ No newline at end of file + ], + "compilerOptions": { + "resolveJsonModule": true + } +} From 3899cd5b97168c1cc312578fec141c4d65df4d19 Mon Sep 17 00:00:00 2001 From: Siddhi doshi Date: Tue, 15 Oct 2024 18:23:00 +0530 Subject: [PATCH 2/2] fix: lint issue --- libs/movex-server/src/lib/movex-server.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/movex-server/src/lib/movex-server.ts b/libs/movex-server/src/lib/movex-server.ts index e03e7f5c..54999def 100644 --- a/libs/movex-server/src/lib/movex-server.ts +++ b/libs/movex-server/src/lib/movex-server.ts @@ -154,7 +154,15 @@ export const movexServer = ( const ridObj = toResourceIdentifierObj(rawRid); - if (!isOneOf(ridObj.resourceType, objectKeys(definition.resources))) { + if ( + !isOneOf( + ridObj.resourceType, + objectKeys(definition.resources) as Extract< + keyof TDefinition['resources'], + string + >[] + ) + ) { return res.sendStatus(400); // Bad Request }