diff --git a/lib/jagfx/core/src/configuration/user-preference/user-preference.type.ts b/lib/jagfx/core/src/configuration/user-preference/user-preference.type.ts index 7286b35..dbd1037 100644 --- a/lib/jagfx/core/src/configuration/user-preference/user-preference.type.ts +++ b/lib/jagfx/core/src/configuration/user-preference/user-preference.type.ts @@ -1,5 +1,4 @@ export type UserPreferenceId = string; - export const enum UserPreferenceTarget { Application = 'application', Game = 'game' @@ -27,4 +26,8 @@ export class UserPreferenceCollection extends Map< return collection; } + + public toJson(): UserPreference[] { + return Array.from(this.values()); + } } diff --git a/lib/jagfx/server/src/user-preference/transformer.ts b/lib/jagfx/server/src/user-preference/transformer.ts index 3d7c297..7128882 100644 --- a/lib/jagfx/server/src/user-preference/transformer.ts +++ b/lib/jagfx/server/src/user-preference/transformer.ts @@ -14,6 +14,6 @@ export const toUserPreferencesCollection = ( }); } ); - + return collection; }; diff --git a/makefile b/makefile index 630ec1a..480c4d7 100644 --- a/makefile +++ b/makefile @@ -28,5 +28,8 @@ ci: server\:dev\:build: @bin/node npm run build -w servers/jagfx/dev +server\:dev\:watch: + @bin/server npm run watch -w servers/jagfx/dev + server\:dev\:start: - @bin/server npm run start -w servers/jagfx/dev \ No newline at end of file + @bin/server npm start -w servers/jagfx/dev \ No newline at end of file diff --git a/servers/jagfx/dev/package.json b/servers/jagfx/dev/package.json index 42cbbc2..58c131b 100644 --- a/servers/jagfx/dev/package.json +++ b/servers/jagfx/dev/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "build": "npx tsc -p tsconfig.json && tsc-alias", - "watch": "npm run build && npx concurrently -c 'tsc -w' 'tsc-alias -w' 'nodemon --experimental-specifier-resolution=node -w dist dist/index.js'", - "start": "nodemon -w src src/index.ts" + "watch": "nodemon -w src src/index.ts", + "start": "nodemon src/index.ts" }, "ts-node": { "esm": true diff --git a/servers/jagfx/dev/src/index.ts b/servers/jagfx/dev/src/index.ts index ba4ee16..d1e5845 100644 --- a/servers/jagfx/dev/src/index.ts +++ b/servers/jagfx/dev/src/index.ts @@ -1,19 +1,19 @@ -import fastify from 'fastify'; +import { UserPreference } from 'ets2-dashboard-core/src/configuration/user-preference/user-preference.type.js'; -import configApplication from 'ets2-dashboard-server/src/config/config.json' assert { type: "json" }; +import configApplication from 'ets2-dashboard-server/src/config/config.json' assert { type: 'json' }; import { toUserPreferencesCollection } from 'ets2-dashboard-server/src/user-preference/transformer.js'; +import fastify from 'fastify'; // https://www.fastify.io/docs/latest/Reference/TypeScript/ const server = fastify(); -server.get('/ping', async (request, reply) => { +server.get('/ping', async () => { return 'pong +66'; }); -server.get('/user-preferences', async (request, reply) => { - console.log( 'Plop' ); - return toUserPreferencesCollection(configApplication); +server.get('/user-preferences', async (): Promise => { + return toUserPreferencesCollection(configApplication).toJson(); }); server.listen({ port: 3000, host: '0.0.0.0' }, (err, address) => {