Skip to content

Commit e08ebd9

Browse files
Merge pull request #237 from Siddhi132/main
fix: linting issues
2 parents fec3b64 + 69f38ff commit e08ebd9

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

libs/movex-server/src/lib/movex-server.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
} from 'movex-master';
2121
import { delay, isOneOf } from './util';
2222

23-
const pkgVersion = require('../../package.json').version;
24-
23+
import { version as pkgVersion } from '../../package.json';
24+
import { ResourceIdentifier } from 'movex-core-util';
2525
const logsy = globalLogsy.withNamespace('[MovexServer]');
2626

2727
logsy.onLog((event) => {
@@ -144,22 +144,32 @@ export const movexServer = <TDefinition extends MovexDefinition>(
144144
// });
145145

146146
app.get('/api/resources/:rid', async (req, res) => {
147-
const rawRid = req.params.rid;
147+
const rawRid = req.params.rid as ResourceIdentifier<
148+
Extract<keyof TDefinition['resources'], string>
149+
>;
148150

149151
if (!isResourceIdentifier(rawRid)) {
150152
return res.sendStatus(400); // Bad Request
151153
}
152154

153155
const ridObj = toResourceIdentifierObj(rawRid);
154156

155-
if (!isOneOf(ridObj.resourceType, objectKeys(definition.resources))) {
157+
if (
158+
!isOneOf(
159+
ridObj.resourceType,
160+
objectKeys(definition.resources) as Extract<
161+
keyof TDefinition['resources'],
162+
string
163+
>[]
164+
)
165+
) {
156166
return res.sendStatus(400); // Bad Request
157167
}
158168

159169
res.header('Content-Type', 'application/json');
160170

161171
return store
162-
.get(rawRid as any) // TODO: Not sure why this doesn't see it and needs to be casted to any?
172+
.get(rawRid)
163173
.map((data) => {
164174
res.send(JSON.stringify(data, null, 4));
165175
})
@@ -217,8 +227,6 @@ export const movexServer = <TDefinition extends MovexDefinition>(
217227
// start the server
218228
const port = process.env['port'] || 3333;
219229
httpServer.listen(port, () => {
220-
const address = httpServer.address();
221-
222230
// console.log(`[movex-server] v${pkgVersion} started at port ${port}.`);
223231

224232
// if (typeof address !== 'string') {

libs/movex-server/tsconfig.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
{
1010
"path": "./tsconfig.spec.json"
1111
}
12-
]
13-
}
12+
],
13+
"compilerOptions": {
14+
"resolveJsonModule": true
15+
}
16+
}

0 commit comments

Comments
 (0)