From bfbc0134de85d34601f3f46366c911bcbc2d0d59 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 23 Sep 2023 16:24:32 +0000 Subject: [PATCH] wip --- @sammo/api_def/src/gateway.ts | 1 - @sammo/client/package.json | 2 + @sammo/client/tsconfig.node.json | 2 +- @sammo/gateway_client/package.json | 1 + @sammo/gateway_client/tsconfig.node.json | 2 +- @sammo/gateway_server/package.json | 12 +- .../gateway_server/src/api/Login/LoginByID.ts | 3 +- .../src/api/Login/LoginByToken.ts | 6 +- @sammo/gateway_server/src/api/Login/index.ts | 2 - @sammo/gateway_server/src/dotenv.ts | 2 +- @sammo/gateway_server/src/exports.ts | 4 +- @sammo/gateway_server/src/gatewayConfig.ts | 7 - @sammo/gateway_server/src/index.ts | 10 +- @sammo/gateway_server/tsconfig.json | 6 + @sammo/server/package.json | 4 +- @sammo/server/src/MongoSequence.ts | 25 ++++ @sammo/server/src/connectDB.ts | 2 +- @sammo/server/src/constPath.ts | 3 + @sammo/server/src/dotenv.ts | 49 +++++++ .../server/src/procDecorator/ReqGameLogin.ts | 15 +- @sammo/server/src/procDecorator/ReqLogin.ts | 6 +- @sammo/server/src/schema/SchemaSequence.ts | 23 ++++ @sammo/server/tsconfig.json | 9 ++ @sammo/server_util/package.json | 1 + @sammo/server_util/src/StartSession.ts | 2 +- @strpc/express/package.json | 1 + @strpc/express/src/generator.ts | 6 +- @strpc/express/src/proc_decorator.ts | 3 +- pnpm-lock.yaml | 129 +++++++++++++++++- tsconfig.json | 33 ++--- tsconfig.server.json | 114 ---------------- 31 files changed, 304 insertions(+), 181 deletions(-) delete mode 100644 @sammo/gateway_server/src/gatewayConfig.ts create mode 100644 @sammo/server/src/MongoSequence.ts create mode 100644 @sammo/server/src/constPath.ts create mode 100644 @sammo/server/src/dotenv.ts create mode 100644 @sammo/server/src/schema/SchemaSequence.ts delete mode 100644 tsconfig.server.json diff --git a/@sammo/api_def/src/gateway.ts b/@sammo/api_def/src/gateway.ts index d6d87ec..80f5224 100644 --- a/@sammo/api_def/src/gateway.ts +++ b/@sammo/api_def/src/gateway.ts @@ -61,7 +61,6 @@ export const structure = { token_id: number, }, AutoLoginResponse, AutoLoginFailed>(), ReqNonce: GET(), - test: GET<{result: true, hello:'world'}>(), }, GetGameLoginToken: GET<{ result: true, diff --git a/@sammo/client/package.json b/@sammo/client/package.json index 5ad8750..31e2b5f 100644 --- a/@sammo/client/package.json +++ b/@sammo/client/package.json @@ -17,6 +17,7 @@ "license": "MIT", "dependencies": { "@popperjs/core": "^2.11.8", + "@sammo/game_logic": "workspace:^", "@sammo/util": "workspace:^", "@strpc/def": "workspace:^", "bootstrap": "^5.3.1", @@ -30,6 +31,7 @@ "vue-router": "^4.2.4" }, "devDependencies": { + "@tsconfig/node20": "^20.1.2", "@types/lodash-es": "^4.17.9", "@types/node": "^20.6.3", "@vue/eslint-config-prettier": "^8.0.0", diff --git a/@sammo/client/tsconfig.node.json b/@sammo/client/tsconfig.node.json index a22705f..9ccb58a 100644 --- a/@sammo/client/tsconfig.node.json +++ b/@sammo/client/tsconfig.node.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node18/tsconfig.json", + "extends": "@tsconfig/node20/tsconfig.json", "include": [ "vite.config.*", "vitest.config.*", diff --git a/@sammo/gateway_client/package.json b/@sammo/gateway_client/package.json index e79558d..7707322 100644 --- a/@sammo/gateway_client/package.json +++ b/@sammo/gateway_client/package.json @@ -30,6 +30,7 @@ "vue-router": "^4.2.4" }, "devDependencies": { + "@tsconfig/node20": "^20.1.2", "@types/lodash-es": "^4.17.9", "@types/node": "^20.6.3", "@vue/eslint-config-prettier": "^8.0.0", diff --git a/@sammo/gateway_client/tsconfig.node.json b/@sammo/gateway_client/tsconfig.node.json index a22705f..9ccb58a 100644 --- a/@sammo/gateway_client/tsconfig.node.json +++ b/@sammo/gateway_client/tsconfig.node.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node18/tsconfig.json", + "extends": "@tsconfig/node20/tsconfig.json", "include": [ "vite.config.*", "vitest.config.*", diff --git a/@sammo/gateway_server/package.json b/@sammo/gateway_server/package.json index a4930b6..2476260 100644 --- a/@sammo/gateway_server/package.json +++ b/@sammo/gateway_server/package.json @@ -15,13 +15,23 @@ "license": "MIT", "dependencies": { "@sammo/api_def": "workspace:^", + "@sammo/crypto": "workspace:^", "@sammo/server_util": "workspace:^", "@sammo/util": "workspace:^", "@strpc/express": "workspace:^", + "date-fns": "^2.30.0", "dotenv": "^16.3.1", - "mongoose": "^7.4.3" + "express": "^4.18.2", + "express-session": "^1.17.3", + "lodash-es": "^4.17.21", + "mongoose": "^7.4.3", + "reflect-metadata": "^0.1.13", + "tslib": "^2.6.2", + "zod": "^3.22.2" }, "devDependencies": { + "@types/express": "^4.17.17", + "@types/express-session": "^1.17.7", "@types/node": "^20.6.3" } } diff --git a/@sammo/gateway_server/src/api/Login/LoginByID.ts b/@sammo/gateway_server/src/api/Login/LoginByID.ts index 7a476e2..dd1f1e2 100644 --- a/@sammo/gateway_server/src/api/Login/LoginByID.ts +++ b/@sammo/gateway_server/src/api/Login/LoginByID.ts @@ -47,7 +47,8 @@ export const LoginByID = POST(LoginByIDReq)(declProcDecorators( userID, userName, userLevel, - allowServerAction: new Set(), + allowServerAction: new Map(), + allowGatewayAction: new Set(), loginDate: new Date(), } diff --git a/@sammo/gateway_server/src/api/Login/LoginByToken.ts b/@sammo/gateway_server/src/api/Login/LoginByToken.ts index 88e998b..3b9fa9a 100644 --- a/@sammo/gateway_server/src/api/Login/LoginByToken.ts +++ b/@sammo/gateway_server/src/api/Login/LoginByToken.ts @@ -3,7 +3,8 @@ import { StartSession } from "@sammo/server_util"; import { POST, type APIReturnType } from "@strpc/express"; import { declProcDecorators } from "@strpc/express/proc_decorator"; import { z } from "zod"; -import { loginCtxSessionKey, type GatewayLoginCtx } from "../../procDecorator/ReqGatewayLogin.js"; +import { loginCtxSessionKey, type GatewayLoginCtx } from "@/procDecorator/ReqGatewayLogin.js"; +import { delay } from "@sammo/util"; type BaseAPI = typeof structure.Login.LoginByToken; type RType = APIReturnType; @@ -16,7 +17,7 @@ const LoginByTokenReq = z.object({ export const LoginByToken = POST(LoginByTokenReq)(declProcDecorators( StartSession, )) - (async (query, ctx) => { + (async (query, ctx): RType => { query.hashedToken; ctx.session.clear(); @@ -33,6 +34,7 @@ export const LoginByToken = POST(LoginByTokenReq)(declProcDecorators( userName, userLevel, allowServerAction: new Map(), + allowGatewayAction: new Set(), loginDate: new Date(), } diff --git a/@sammo/gateway_server/src/api/Login/index.ts b/@sammo/gateway_server/src/api/Login/index.ts index 38bee8c..226a311 100644 --- a/@sammo/gateway_server/src/api/Login/index.ts +++ b/@sammo/gateway_server/src/api/Login/index.ts @@ -3,11 +3,9 @@ import type { APINamespaceType } from "@strpc/express"; import { LoginByID } from "./LoginByID.js"; import { LoginByToken } from "./LoginByToken.js"; import { ReqNonce } from "./ReqNonce.js"; -import { test } from "./test.js"; export const Login = { LoginByID, LoginByToken, ReqNonce, - test, } satisfies APINamespaceType; \ No newline at end of file diff --git a/@sammo/gateway_server/src/dotenv.ts b/@sammo/gateway_server/src/dotenv.ts index f9ce3ca..3273dc1 100644 --- a/@sammo/gateway_server/src/dotenv.ts +++ b/@sammo/gateway_server/src/dotenv.ts @@ -31,7 +31,7 @@ function generateConfig() { return { port: parseInt(process.env['SERVER_PORT'] ?? "3001"), sessionSecret: unwrap(process.env['SESSION_SECRET']), - apiRootPath: process.env['API_ROOT_PATH'] ?? '/api/gateway', + apiRootPath: process.env['API_ROOT_PATH'] ?? '/api', } as const; } diff --git a/@sammo/gateway_server/src/exports.ts b/@sammo/gateway_server/src/exports.ts index 8013193..0a30fcf 100644 --- a/@sammo/gateway_server/src/exports.ts +++ b/@sammo/gateway_server/src/exports.ts @@ -2,8 +2,8 @@ export type { ServerActionType, UserIDType, IUser, -} from "./schema/User.ts"; +} from "./schema/User.js"; export type { ILoginToken -} from "./schema/LoginToken.ts"; \ No newline at end of file +} from "./schema/LoginToken.js"; \ No newline at end of file diff --git a/@sammo/gateway_server/src/gatewayConfig.ts b/@sammo/gateway_server/src/gatewayConfig.ts deleted file mode 100644 index 08c69f7..0000000 --- a/@sammo/gateway_server/src/gatewayConfig.ts +++ /dev/null @@ -1,7 +0,0 @@ -import 'dotenv/config'; -import { unwrap } from "@sammo/util"; - -export const gatewayConfig = { - sessionSecret: unwrap(process.env.GATEWAY_SESSION_SECRET), - port: Number(unwrap(process.env.GATEWAY_PORT)), -}; \ No newline at end of file diff --git a/@sammo/gateway_server/src/index.ts b/@sammo/gateway_server/src/index.ts index 0fe4108..687aa12 100644 --- a/@sammo/gateway_server/src/index.ts +++ b/@sammo/gateway_server/src/index.ts @@ -1,15 +1,15 @@ import './dotenv.js' +import { ownConfig } from './dotenv.js'; import 'reflect-metadata'; import gatewayDB from './connectDB.js'; import express, { type Request, type Response } from "express" import session from "express-session"; import { buildAPISystem } from '@strpc/express/generator'; -//import { sammoGatewayAPI } from './api/index.js'; -import { unwrap } from '@sammo/util';; -import { gatewayConfig } from './gatewayConfig.js'; - +import { sammoGatewayAPI } from './api/index.js'; +import { unwrap } from '@sammo/util'; +const gatewayConfig = ownConfig(); gatewayDB.then(async (gatewayDB) => { // create express app @@ -22,7 +22,7 @@ gatewayDB.then(async (gatewayDB) => { })) //app.set('etag', false); - //app.use('/gateway_api', buildAPISystem(sammoGatewayAPI)); + app.use('/gateway_api', buildAPISystem(sammoGatewayAPI)); // start express server app.listen(gatewayConfig.port) diff --git a/@sammo/gateway_server/tsconfig.json b/@sammo/gateway_server/tsconfig.json index ebff90d..9654247 100644 --- a/@sammo/gateway_server/tsconfig.json +++ b/@sammo/gateway_server/tsconfig.json @@ -3,11 +3,17 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./dist", + "paths": { + "@/*": ["./src/*"] + } }, "references": [ { "path": "../../@strpc/express" }, + { + "path": "../api_def" + }, { "path": "../util" }, diff --git a/@sammo/server/package.json b/@sammo/server/package.json index 829a1a9..7da8f67 100644 --- a/@sammo/server/package.json +++ b/@sammo/server/package.json @@ -29,7 +29,9 @@ "zod": "^3.22.2" }, "devDependencies": { - "@sammo/gateway": "workspace:^", + "@types/express": "^4.17.17", + "@types/express-session": "^1.17.7", + "@sammo/gateway_server": "workspace:^", "@types/node": "^20.6.3" } } diff --git a/@sammo/server/src/MongoSequence.ts b/@sammo/server/src/MongoSequence.ts new file mode 100644 index 0000000..008d4a0 --- /dev/null +++ b/@sammo/server/src/MongoSequence.ts @@ -0,0 +1,25 @@ +import type { StateIncrementer } from '@sammo/server_util'; +import SchemaSequence from './schema/SchemaSequence.js'; +import { InvalidArgument } from '@sammo/util'; + +export function MongoSequenceFactory(collectionName: string): StateIncrementer{ + + return async (increase: number) => { + if(increase <= 0){ + throw new InvalidArgument('increase must be > 0'); + } + increase = Math.ceil(increase); + + const result = await SchemaSequence.findOneAndUpdate({ + collectionName, + }, { + $inc: { + nextSeq: increase, + }, + }, { + upsert: true, + new: true, + }); + return result.nextSeq; + } +} \ No newline at end of file diff --git a/@sammo/server/src/connectDB.ts b/@sammo/server/src/connectDB.ts index c37ea01..ab33459 100644 --- a/@sammo/server/src/connectDB.ts +++ b/@sammo/server/src/connectDB.ts @@ -1,6 +1,6 @@ import 'dotenv/config'; import { connect, Mongoose } from "mongoose"; -import { unwrap } from './util/unwrap.js'; +import { unwrap } from '@sammo/util'; const dbConfig = { host: unwrap(process.env.GAME_DB_HOST), diff --git a/@sammo/server/src/constPath.ts b/@sammo/server/src/constPath.ts new file mode 100644 index 0000000..f00e15f --- /dev/null +++ b/@sammo/server/src/constPath.ts @@ -0,0 +1,3 @@ +import { resolve } from "node:path"; + +export const rootPath = resolve(resolve(), '../..'); \ No newline at end of file diff --git a/@sammo/server/src/dotenv.ts b/@sammo/server/src/dotenv.ts new file mode 100644 index 0000000..ccebd03 --- /dev/null +++ b/@sammo/server/src/dotenv.ts @@ -0,0 +1,49 @@ +import dotenv from 'dotenv'; +import { rootPath } from './constPath.js'; +import { unwrap } from '@sammo/util'; + +let init = false; +const dirPath = rootPath +console.log(rootPath); + +function initDotEnv() { + if (process.env['NODE_ENV'] == 'production') { + dotenv.config({ path: `${dirPath}/.env.production.local` }); + dotenv.config({ path: `${dirPath}/.env.local` }); + dotenv.config({ path: `${dirPath}/.env.production` }); + } + else { + dotenv.config({ path: `${dirPath}/.env.development.local` }); + dotenv.config({ path: `${dirPath}/.env.local` }); + dotenv.config({ path: `${dirPath}/.env.development` }); + } + dotenv.config(); + init = true; +} + +if (!init) { + initDotEnv(); +} + +let _ownConfig: ReturnType|undefined = undefined; + +function generateConfig() { + return { + port: parseInt(process.env['SERVER_PORT'] ?? "3001"), + sessionSecret: unwrap(process.env['SESSION_SECRET']), + gatewayHost: unwrap(process.env.GATEWAY_HOST), + gatewayPort: Number(unwrap(process.env.GATEWAY_PORT)), + apiRootPath: process.env['API_ROOT_PATH'] ?? '/api', + } as const; +} + +export function serverConfig() { + if(_ownConfig !== undefined){ + return _ownConfig; + } + if(!init){ + initDotEnv(); + } + _ownConfig = generateConfig(); + return _ownConfig; +} diff --git a/@sammo/server/src/procDecorator/ReqGameLogin.ts b/@sammo/server/src/procDecorator/ReqGameLogin.ts index 12ff76a..850ee1a 100644 --- a/@sammo/server/src/procDecorator/ReqGameLogin.ts +++ b/@sammo/server/src/procDecorator/ReqGameLogin.ts @@ -1,6 +1,6 @@ +import type { SessionCtx } from "@sammo/server_util"; import type { LoginCtx } from "./ReqLogin.js"; -import type { SessionCtx } from "./StartSession.js"; -import type { ProcDecoratorGenerator } from "./base.js"; +import type { ProcDecoratorGenerator } from "@strpc/express/proc_decorator"; export type GameLoginCtx = { generalID: number; @@ -12,11 +12,11 @@ export function ReqGameLogin(): ProcDecoratorGe return async (ctx) => { //NOTE: 게임 서버별로 gameLoginCtx를 따로 가져야 하는가? let gameLoginCtx = ctx.session.getItem(`gameLoginCtx`); - if(gameLoginCtx){ - if(gameLoginCtx.gameLoginDate >= ctx.loginDate){ + if (gameLoginCtx) { + if (gameLoginCtx.gameLoginDate >= ctx.loginDate) { return [{ result: true, - },{ + }, { ...gameLoginCtx, ...ctx, }]; @@ -25,11 +25,12 @@ export function ReqGameLogin(): ProcDecoratorGe } //TODO: DB에서 generalID를 가져오는 로직 - return [{ result: false, type: 'Required GameLogin', info: 'NotYetImplemented' - }, ctx]; + }, { + ...ctx + }]; } } \ No newline at end of file diff --git a/@sammo/server/src/procDecorator/ReqLogin.ts b/@sammo/server/src/procDecorator/ReqLogin.ts index df30249..c3f3c84 100644 --- a/@sammo/server/src/procDecorator/ReqLogin.ts +++ b/@sammo/server/src/procDecorator/ReqLogin.ts @@ -1,6 +1,6 @@ -import type { ServerActionType } from "../schema/gateway/User.js"; -import type { SessionCtx } from "./StartSession.js"; -import type { ProcDecorator } from "./base.js"; +import type { SessionCtx } from "@sammo/server_util"; +import type { ProcDecorator } from "@strpc/express/proc_decorator"; +import type { ServerActionType } from "@sammo/gateway_server/exports" export type LoginCtx = { userID: number; diff --git a/@sammo/server/src/schema/SchemaSequence.ts b/@sammo/server/src/schema/SchemaSequence.ts new file mode 100644 index 0000000..2c6e2e2 --- /dev/null +++ b/@sammo/server/src/schema/SchemaSequence.ts @@ -0,0 +1,23 @@ +import { Schema, model, Types } from 'mongoose'; + +interface ISchemaSequence { + _id: Types.ObjectId; + + collectionName: string; + nextSeq: number; +} + +export const SchemaSequence = new Schema({ + collectionName: { type: String, required: true }, + nextSeq: { + type: Number, required: true, + get: (v: number) => Math.ceil(v), + set: (v: number) => Math.ceil(v), + default: 0, + }, + +}, { autoIndex: true, autoCreate: true }) + .index({ collectionName: 1 }, { unique: true }) + ; + +export default model('SchemaSequence', SchemaSequence); \ No newline at end of file diff --git a/@sammo/server/tsconfig.json b/@sammo/server/tsconfig.json index ebff90d..4183b97 100644 --- a/@sammo/server/tsconfig.json +++ b/@sammo/server/tsconfig.json @@ -3,6 +3,9 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./dist", + "paths": { + "@/*": ["./src/*"] + } }, "references": [ { @@ -17,5 +20,11 @@ { "path": "../server_util" }, + { + "path": "../api_def" + }, + { + "path": "../gateway_server" + } ] } diff --git a/@sammo/server_util/package.json b/@sammo/server_util/package.json index 5c69aa4..3131d02 100644 --- a/@sammo/server_util/package.json +++ b/@sammo/server_util/package.json @@ -16,6 +16,7 @@ "@strpc/express": "workspace:^" }, "devDependencies": { + "@types/express-session": "^1.17.7", "lodash-es": "^4.17.21" }, "peerDependencies": { diff --git a/@sammo/server_util/src/StartSession.ts b/@sammo/server_util/src/StartSession.ts index 817365f..ae23a35 100644 --- a/@sammo/server_util/src/StartSession.ts +++ b/@sammo/server_util/src/StartSession.ts @@ -1,5 +1,5 @@ import type { Empty, ProcDecoratorGenerator } from "@strpc/express/proc_decorator"; -import { type Session, type SessionData } from "express-session"; +import type { Session, SessionData } from "express-session"; export type SessionCtx = { session: { diff --git a/@strpc/express/package.json b/@strpc/express/package.json index 9f15d00..3dd1a05 100644 --- a/@strpc/express/package.json +++ b/@strpc/express/package.json @@ -18,6 +18,7 @@ "@strpc/def": "workspace:^" }, "devDependencies": { + "@types/express": "^4.17.17", "express": "^4.18.2", "express-session": "^1.17.3", "lodash-es": "^4.17.21", diff --git a/@strpc/express/src/generator.ts b/@strpc/express/src/generator.ts index ca5dbba..54fd46c 100644 --- a/@strpc/express/src/generator.ts +++ b/@strpc/express/src/generator.ts @@ -1,7 +1,7 @@ import { Router, type Request, type Response } from 'express'; import type { AnyAPIExecuter, APINamespace } from './defs.js'; import type { RawArgType } from '@strpc/def'; -import type { SafeParseReturnType, ZodType, z } from 'zod'; +import type { SafeParseReturnType, ZodType } from 'zod'; import { flatten } from 'lodash-es'; const PRINT_API_CALL = true; @@ -107,14 +107,14 @@ async function apiRun(query: Q, req: Request, res: Respons let tmp_result = true; let tmp_reason = undefined; if('result' in result){ - tmp_result = result.result; + tmp_result = result.result; } if('reason' in result){ tmp_reason = result.reason; } console.log(JSON.stringify([(new Date).toISOString(), req.ip, req.path, tmp_result, tmp_reason])); } - + } if (result !== true) { diff --git a/@strpc/express/src/proc_decorator.ts b/@strpc/express/src/proc_decorator.ts index 33d212b..da17d98 100644 --- a/@strpc/express/src/proc_decorator.ts +++ b/@strpc/express/src/proc_decorator.ts @@ -21,8 +21,7 @@ export type DecoratorStack = DecoratorResult[]; export interface ProcDecorator { (inCtx: In & Partial, req: Request, res: Response) - : MayBePromise<[DecoratorResultTrue, Out]> - | MayBePromise<[DecoratorResultFalse, In & Partial]>; + : MayBePromise<[DecoratorResultTrue, Out] | [DecoratorResultFalse, In & Partial]>; } export interface PostProcDecorator { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 06b8a8e..24e3709 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: '@popperjs/core': specifier: ^2.11.8 version: 2.11.8 + '@sammo/game_logic': + specifier: workspace:^ + version: link:../game_logic '@sammo/util': specifier: workspace:^ version: link:../util @@ -109,6 +112,9 @@ importers: specifier: ^4.2.4 version: 4.2.4(vue@3.3.4) devDependencies: + '@tsconfig/node20': + specifier: ^20.1.2 + version: 20.1.2 '@types/lodash-es': specifier: ^4.17.9 version: 4.17.9 @@ -262,6 +268,9 @@ importers: specifier: ^4.2.4 version: 4.2.4(vue@3.3.4) devDependencies: + '@tsconfig/node20': + specifier: ^20.1.2 + version: 20.1.2 '@types/lodash-es': specifier: ^4.17.9 version: 4.17.9 @@ -307,6 +316,9 @@ importers: '@sammo/api_def': specifier: workspace:^ version: link:../api_def + '@sammo/crypto': + specifier: workspace:^ + version: link:../crypto '@sammo/server_util': specifier: workspace:^ version: link:../server_util @@ -316,13 +328,40 @@ importers: '@strpc/express': specifier: workspace:^ version: link:../../@strpc/express + date-fns: + specifier: ^2.30.0 + version: 2.30.0 dotenv: specifier: ^16.3.1 version: 16.3.1 + express: + specifier: ^4.18.2 + version: 4.18.2 + express-session: + specifier: ^1.17.3 + version: 1.17.3 + lodash-es: + specifier: ^4.17.21 + version: 4.17.21 mongoose: specifier: ^7.4.3 version: 7.4.3 + reflect-metadata: + specifier: ^0.1.13 + version: 0.1.13 + tslib: + specifier: ^2.6.2 + version: 2.6.2 + zod: + specifier: ^3.22.2 + version: 3.22.2 devDependencies: + '@types/express': + specifier: ^4.17.17 + version: 4.17.17 + '@types/express-session': + specifier: ^1.17.7 + version: 1.17.7 '@types/node': specifier: ^20.6.3 version: 20.6.3 @@ -400,9 +439,15 @@ importers: specifier: ^3.22.2 version: 3.22.2 devDependencies: - '@sammo/gateway': + '@sammo/gateway_server': specifier: workspace:^ version: link:../gateway_server + '@types/express': + specifier: ^4.17.17 + version: 4.17.17 + '@types/express-session': + specifier: ^1.17.7 + version: 1.17.7 '@types/node': specifier: ^20.6.3 version: 20.6.3 @@ -419,6 +464,9 @@ importers: specifier: workspace:^ version: link:../../@strpc/express devDependencies: + '@types/express-session': + specifier: ^1.17.7 + version: 1.17.7 lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -453,6 +501,9 @@ importers: specifier: workspace:^ version: link:../def devDependencies: + '@types/express': + specifier: ^4.17.17 + version: 4.17.17 express: specifier: ^4.18.2 version: 4.18.2 @@ -1553,6 +1604,10 @@ packages: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} dev: true + /@tsconfig/node20@20.1.2: + resolution: {integrity: sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==} + dev: true + /@types/babel__core@7.20.2: resolution: {integrity: sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==} dependencies: @@ -1582,12 +1637,53 @@ packages: '@babel/types': 7.22.5 dev: true + /@types/body-parser@1.19.3: + resolution: {integrity: sha512-oyl4jvAfTGX9Bt6Or4H9ni1Z447/tQuxnZsytsCaExKlmJiU8sFgnIBRzJUpKwB5eWn9HuBYlUlVA74q/yN0eQ==} + dependencies: + '@types/connect': 3.4.36 + '@types/node': 20.6.3 + dev: true + + /@types/connect@3.4.36: + resolution: {integrity: sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==} + dependencies: + '@types/node': 20.6.3 + dev: true + + /@types/express-serve-static-core@4.17.36: + resolution: {integrity: sha512-zbivROJ0ZqLAtMzgzIUC4oNqDG9iF0lSsAqpOD9kbs5xcIM3dTiyuHvBc7R8MtWBp3AAWGaovJa+wzWPjLYW7Q==} + dependencies: + '@types/node': 20.6.3 + '@types/qs': 6.9.8 + '@types/range-parser': 1.2.4 + '@types/send': 0.17.1 + dev: true + + /@types/express-session@1.17.7: + resolution: {integrity: sha512-L25080PBYoRLu472HY/HNCxaXY8AaGgqGC8/p/8+BYMhG0RDOLQ1wpXOpAzr4Gi5TGozTKyJv5BVODM5UNyVMw==} + dependencies: + '@types/express': 4.17.17 + dev: true + + /@types/express@4.17.17: + resolution: {integrity: sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==} + dependencies: + '@types/body-parser': 1.19.3 + '@types/express-serve-static-core': 4.17.36 + '@types/qs': 6.9.8 + '@types/serve-static': 1.15.2 + dev: true + /@types/graceful-fs@4.1.7: resolution: {integrity: sha512-MhzcwU8aUygZroVwL2jeYk6JisJrPl/oov/gsgGCue9mkgl9wjGbzReYQClxiUgFDnib9FuHqTndccKeZKxTRw==} dependencies: '@types/node': 20.6.3 dev: true + /@types/http-errors@2.0.2: + resolution: {integrity: sha512-lPG6KlZs88gef6aD85z3HNkztpj7w2R7HmR3gygjfXCQmsLloWNARFkMuzKiiY8FGdh1XDpgBdrSf4aKDiA7Kg==} + dev: true + /@types/istanbul-lib-coverage@2.0.4: resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} dev: true @@ -1635,6 +1731,14 @@ packages: resolution: {integrity: sha512-trNJ/vtMZYMLhfN45uLq4ShQSw0/S7xCTLLVM+WM1rmFpba/VS42jVUgaO3w/NOLiWR/09lnYk0yMaA/atdIsg==} dev: true + /@types/mime@1.3.2: + resolution: {integrity: sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==} + dev: true + + /@types/mime@3.0.1: + resolution: {integrity: sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==} + dev: true + /@types/node@18.17.0: resolution: {integrity: sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==} dev: true @@ -1642,10 +1746,33 @@ packages: /@types/node@20.6.3: resolution: {integrity: sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==} + /@types/qs@6.9.8: + resolution: {integrity: sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg==} + dev: true + + /@types/range-parser@1.2.4: + resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==} + dev: true + /@types/semver@7.5.0: resolution: {integrity: sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==} dev: true + /@types/send@0.17.1: + resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} + dependencies: + '@types/mime': 1.3.2 + '@types/node': 20.6.3 + dev: true + + /@types/serve-static@1.15.2: + resolution: {integrity: sha512-J2LqtvFYCzaj8pVYKw8klQXrLLk7TBZmQ4ShlcdkELFKGwGMfevMLneMMRkMgZxotOD9wg497LpC7O8PcvAmfw==} + dependencies: + '@types/http-errors': 2.0.2 + '@types/mime': 3.0.1 + '@types/node': 20.6.3 + dev: true + /@types/stack-utils@2.0.1: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true diff --git a/tsconfig.json b/tsconfig.json index 38cd8be..5f408c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,17 @@ { - "files": [], + "extends": "./tsconfig.base.json", "references": [ { - "path": "./tsconfig.node.json" + "path": "./@sammo/gateway_client" }, { - "path": "./tsconfig.app.json" + "path": "./@sammo/gateway_server" + }, + { + "path": "./@sammo/server" + }, + { + "path": "./@sammo/client" }, ], - "compilerOptions": { - "experimentalDecorators": true, - "emitDecoratorMetadata": true, - "module": "ESNext", - "moduleResolution": "node", - "resolveJsonModule": true, - "importHelpers": true, - "isolatedModules": true, - "verbatimModuleSyntax": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "paths": { - "@util/*": ["./server/util/*"], - "@server/*": ["./server/*"], - } - } } diff --git a/tsconfig.server.json b/tsconfig.server.json deleted file mode 100644 index b1357d1..0000000 --- a/tsconfig.server.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ - "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "lib": [ - "ESNext" - ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - /* Modules */ - "module": "ESNext", /* Specify what module code is generated. */ - "rootDir": "./server", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": ".", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./dist_server/", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "error", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - /* Interop Constraints */ - "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "paths": { - "@util/*": ["./util/*"], - "@server/*": ["./*"], - } - }, - "include": [ - "./server/**/*" - ], - "ts-node": { - "esm": true, - "experimentalSpecifierResolution": "node" - } -} \ No newline at end of file