@dooboostore/simple-boot-http-server 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/SimpleBootHttpServer.js +2 -1
- package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
- package/dist/cjs/decorators/MethodMapping.js +9 -0
- package/dist/cjs/decorators/MethodMapping.js.map +2 -2
- package/dist/cjs/models/RequestResponse.js +15 -2
- package/dist/cjs/models/RequestResponse.js.map +2 -2
- package/dist/cjs/option/HttpServerOption.js +2 -1
- package/dist/cjs/option/HttpServerOption.js.map +2 -2
- package/dist/esm/SimpleBootHttpServer.js +2 -1
- package/dist/esm/SimpleBootHttpServer.js.map +2 -2
- package/dist/esm/decorators/MethodMapping.js +9 -0
- package/dist/esm/decorators/MethodMapping.js.map +2 -2
- package/dist/esm/models/RequestResponse.js +15 -2
- package/dist/esm/models/RequestResponse.js.map +2 -2
- package/dist/esm/option/HttpServerOption.js +2 -1
- package/dist/esm/option/HttpServerOption.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +64 -23
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +2 -2
- package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
- package/dist/types/models/RequestResponse.d.ts.map +1 -1
- package/dist/types/option/HttpServerOption.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +64 -23
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +2 -2
- package/package.json +3 -3
- package/src/SimpleBootHttpServer.ts +4 -1
- package/src/decorators/MethodMapping.ts +9 -0
- package/src/models/RequestResponse.ts +18 -2
- package/src/option/HttpServerOption.ts +8 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/option/HttpServerOption.ts"],
|
|
4
|
-
"sourcesContent": ["import { InitOptionType, SimOption } from '@dooboostore/simple-boot';\nimport { ConstructorType } from '@dooboostore/core';\nimport { Server as HttpServer, ServerOptions } from 'http';\nimport { Server as HttpsServer, ServerOptions as HttpsServerOption } from 'https';\nimport { Filter } from '../filters/Filter';\nimport { EndPoint } from '../endpoints/EndPoint';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { TransactionManager } from '@dooboostore/core';\nimport { WebSocketEndPoint } from '../endpoints/WebSocketEndPoint';\n\nexport type Listen = { port?: number, hostname?: string, backlog?: number, listeningListener?: (server: SimpleBootHttpServer, httpServer: HttpServer | HttpsServer) => void };\n\nexport interface ListenData extends Listen {\n port: number;\n hostname: string;\n}\n\nexport type SessionOption = {\n key: string;\n expiredTime: number;\n httpOnly?: boolean;\n secure?: boolean;\n maxAge?: number;\n sameSite?: boolean | 'lax' | 'strict' | 'none';\n domain?: string;\n path?: string;\n provider?: {\n uuids: () => Promise<string[]>;\n delete: (uuid: string) => Promise<void>;\n get: (uuid: string) => Promise<{ access: number; data?: any }>;\n set: (uuid: string, data: { access: number; data?: any }) => Promise<void>;\n };\n};\n\nexport type FilterSupportType = { filter: Filter | ConstructorType<Filter>, isSupport: boolean | ((rr: RequestResponse) => boolean) | RegExp };\n\nexport class HttpServerOption extends SimOption {\n public static readonly DEFAULT_PORT = 8081;\n public static readonly DEFAULT_HOSTNAME = '127.0.0.1';\n public serverOption?: ServerOptions | HttpsServerOption;\n public listen: ListenData;\n public filters?: FilterSupportType[];\n public fileUploadTempPath?: string;\n public requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public webSocketEndPoints?: (WebSocketEndPoint | ConstructorType<WebSocketEndPoint>)[];\n public closeEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public errorEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public sessionOption: SessionOption;\n public globalAdvice?: any | ConstructorType<any>;\n public noSuchRouteEndPointMappingThrow?: (rr: RequestResponse) => any;\n public transactionManagerFactory?: () => TransactionManager;\n\n constructor(\n {\n serverOption,\n listen,\n filters,\n requestEndPoints,\n closeEndPoints,\n errorEndPoints,\n webSocketEndPoints,\n sessionOption,\n globalAdvice,\n fileUploadTempPath,\n noSuchRouteEndPointMappingThrow,\n transactionManagerFactory\n }: {\n serverOption?: ServerOptions | HttpsServerOption;\n listen?: Listen;\n filters?: (FilterSupportType)[];\n requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n closeEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n errorEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n webSocketEndPoints?: (WebSocketEndPoint | ConstructorType<WebSocketEndPoint>)[];\n sessionOption?: {\n key?: string;\n expiredTime?: number;\n provider?: {\n uuids: () => Promise<string[]>;\n delete: (uuid: string) => Promise<void>;\n get: (uuid: string) => Promise<{ access: number; data?: any }>;\n set: (uuid: string, data: { access: number; data?: any }) => Promise<void>;\n };\n };\n globalAdvice?: any | ConstructorType<any>;\n fileUploadTempPath?: string;\n noSuchRouteEndPointMappingThrow?: (rr: RequestResponse) => any;\n transactionManagerFactory?: () => TransactionManager;\n } = {},\n initSimOption?: InitOptionType\n ) {\n super(initSimOption);\n this.serverOption = serverOption;\n this.listen = Object.assign(\n { port: HttpServerOption.DEFAULT_PORT, hostname: HttpServerOption.DEFAULT_HOSTNAME },\n listen\n );\n this.filters = filters;\n this.requestEndPoints = requestEndPoints;\n this.closeEndPoints = closeEndPoints;\n this.errorEndPoints = errorEndPoints;\n this.webSocketEndPoints = webSocketEndPoints;\n this.sessionOption = Object.assign(\n { key: 'SBSESSIONID', path: '/', httpOnly: true, expiredTime: 1000 * 60 * 30 },\n sessionOption\n );\n this.globalAdvice = globalAdvice;\n this.fileUploadTempPath = fileUploadTempPath;\n this.noSuchRouteEndPointMappingThrow
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA0C;
|
|
4
|
+
"sourcesContent": ["import { InitOptionType, SimOption } from '@dooboostore/simple-boot';\nimport { ConstructorType } from '@dooboostore/core';\nimport { Server as HttpServer, ServerOptions } from 'http';\nimport { Server as HttpsServer, ServerOptions as HttpsServerOption } from 'https';\nimport { Filter } from '../filters/Filter';\nimport { EndPoint } from '../endpoints/EndPoint';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { TransactionManager } from '@dooboostore/core';\nimport { WebSocketEndPoint } from '../endpoints/WebSocketEndPoint';\nimport { NotFoundError } from '../errors/NotFoundError';\n\nexport type Listen = { port?: number, hostname?: string, backlog?: number, listeningListener?: (server: SimpleBootHttpServer, httpServer: HttpServer | HttpsServer) => void };\n\nexport interface ListenData extends Listen {\n port: number;\n hostname: string;\n}\n\nexport type SessionOption = {\n key: string;\n expiredTime: number;\n httpOnly?: boolean;\n secure?: boolean;\n maxAge?: number;\n sameSite?: boolean | 'lax' | 'strict' | 'none';\n domain?: string;\n path?: string;\n provider?: {\n uuids: () => Promise<string[]>;\n delete: (uuid: string) => Promise<void>;\n get: (uuid: string) => Promise<{ access: number; data?: any }>;\n set: (uuid: string, data: { access: number; data?: any }) => Promise<void>;\n };\n};\n\nexport type FilterSupportType = { filter: Filter | ConstructorType<Filter>, isSupport: boolean | ((rr: RequestResponse) => boolean) | RegExp };\n\nexport class HttpServerOption extends SimOption {\n public static readonly DEFAULT_PORT = 8081;\n public static readonly DEFAULT_HOSTNAME = '127.0.0.1';\n public serverOption?: ServerOptions | HttpsServerOption;\n public listen: ListenData;\n public filters?: FilterSupportType[];\n public fileUploadTempPath?: string;\n public requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public webSocketEndPoints?: (WebSocketEndPoint | ConstructorType<WebSocketEndPoint>)[];\n public closeEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public errorEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n public sessionOption: SessionOption;\n public globalAdvice?: any | ConstructorType<any>;\n public noSuchRouteEndPointMappingThrow?: (rr: RequestResponse) => any;\n public transactionManagerFactory?: () => TransactionManager;\n\n constructor(\n {\n serverOption,\n listen,\n filters,\n requestEndPoints,\n closeEndPoints,\n errorEndPoints,\n webSocketEndPoints,\n sessionOption,\n globalAdvice,\n fileUploadTempPath,\n noSuchRouteEndPointMappingThrow,\n transactionManagerFactory\n }: {\n serverOption?: ServerOptions | HttpsServerOption;\n listen?: Listen;\n filters?: (FilterSupportType)[];\n requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n closeEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n errorEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];\n webSocketEndPoints?: (WebSocketEndPoint | ConstructorType<WebSocketEndPoint>)[];\n sessionOption?: {\n key?: string;\n expiredTime?: number;\n provider?: {\n uuids: () => Promise<string[]>;\n delete: (uuid: string) => Promise<void>;\n get: (uuid: string) => Promise<{ access: number; data?: any }>;\n set: (uuid: string, data: { access: number; data?: any }) => Promise<void>;\n };\n };\n globalAdvice?: any | ConstructorType<any>;\n fileUploadTempPath?: string;\n noSuchRouteEndPointMappingThrow?: (rr: RequestResponse) => any;\n transactionManagerFactory?: () => TransactionManager;\n } = {},\n initSimOption?: InitOptionType\n ) {\n super(initSimOption);\n this.serverOption = serverOption;\n this.listen = Object.assign(\n { port: HttpServerOption.DEFAULT_PORT, hostname: HttpServerOption.DEFAULT_HOSTNAME },\n listen\n );\n this.filters = filters;\n this.requestEndPoints = requestEndPoints;\n this.closeEndPoints = closeEndPoints;\n this.errorEndPoints = errorEndPoints;\n this.webSocketEndPoints = webSocketEndPoints;\n this.sessionOption = Object.assign(\n { key: 'SBSESSIONID', path: '/', httpOnly: true, expiredTime: 1000 * 60 * 30 },\n sessionOption\n );\n this.globalAdvice = globalAdvice;\n this.fileUploadTempPath = fileUploadTempPath;\n // Unmatched routes must not fall through to \"200 OK with empty body\"\n // like before. Default to 404 (Express-compatible); users can still\n // override with their own noSuchRouteEndPointMappingThrow.\n this.noSuchRouteEndPointMappingThrow =\n noSuchRouteEndPointMappingThrow ??\n ((rr: RequestResponse) =>\n new NotFoundError({ message: `no route ${rr.reqMethod?.() ?? ''} ${rr.reqUrlPathName ?? ''}`.trim() }));\n this.transactionManagerFactory = transactionManagerFactory;\n }\n\n get hostname() {\n return this.listen.hostname;\n }\n\n get port() {\n return this.listen.port;\n }\n\n get protocol() {\n return this.isSecure ? 'https' : 'http';\n }\n\n get address() {\n return `${this.protocol}://${this.hostname}:${this.port}`;\n }\n\n get isSecure() {\n return this.serverOption && 'key' in this.serverOption && 'cert' in this.serverOption;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA0C;AAU1C,2BAA8B;AA4BvB,MAAM,yBAAyB,6BAAU;AAAA,EAC9C;AAAA,SAAuB,eAAe;AAAA;AAAA,EACtC;AAAA,SAAuB,mBAAmB;AAAA;AAAA,EAc1C,YACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAsBI,CAAC,GACL,eACA;AACA,UAAM,aAAa;AACnB,SAAK,eAAe;AACpB,SAAK,SAAS,OAAO;AAAA,MACnB,EAAE,MAAM,iBAAiB,cAAc,UAAU,iBAAiB,iBAAiB;AAAA,MACnF;AAAA,IACF;AACA,SAAK,UAAU;AACf,SAAK,mBAAmB;AACxB,SAAK,iBAAiB;AACtB,SAAK,iBAAiB;AACtB,SAAK,qBAAqB;AAC1B,SAAK,gBAAgB,OAAO;AAAA,MAC1B,EAAE,KAAK,eAAe,MAAM,KAAK,UAAU,MAAM,aAAa,MAAO,KAAK,GAAG;AAAA,MAC7E;AAAA,IACF;AACA,SAAK,eAAe;AACpB,SAAK,qBAAqB;AAI1B,SAAK,kCACH,oCACC,CAAC,OACA,IAAI,mCAAc,EAAE,SAAS,YAAY,GAAG,YAAY,KAAK,EAAE,IAAI,GAAG,kBAAkB,EAAE,GAAG,KAAK,EAAE,CAAC;AACzG,SAAK,4BAA4B;AAAA,EACnC;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,OAAO;AACT,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,WAAW,UAAU;AAAA,EACnC;AAAA,EAEA,IAAI,UAAU;AACZ,WAAO,GAAG,KAAK,QAAQ,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAI;AAAA,EACzD;AAAA,EAEA,IAAI,WAAW;AACb,WAAO,KAAK,gBAAgB,SAAS,KAAK,gBAAgB,UAAU,KAAK;AAAA,EAC3E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -323,7 +323,8 @@ class SimpleBootHttpServer extends SimpleApplication {
|
|
|
323
323
|
console.error("request error:", e);
|
|
324
324
|
transactionManager?.catch(e);
|
|
325
325
|
rr.resStatusCode(e instanceof HttpError ? e.status : HttpStatus.InternalServerError);
|
|
326
|
-
const
|
|
326
|
+
const globalAdvice = this.option.globalAdvice;
|
|
327
|
+
const execute = typeof globalAdvice === "function" ? this.simstanceManager.getOrNewSim({ target: globalAdvice }) : globalAdvice;
|
|
327
328
|
if (!execute) {
|
|
328
329
|
rr.resEnd();
|
|
329
330
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SimpleBootHttpServer.ts"],
|
|
4
|
-
"sourcesContent": ["import {SimpleApplication} from '@dooboostore/simple-boot';\nimport {HttpServerOption} from './option/HttpServerOption';\nimport {ConstructorType} from '@dooboostore/core';\nimport {IncomingMessage, Server as HttpServer, ServerResponse} from 'http'\nimport {Server as HttpsServer} from 'https'; // Add HTTPS support\nimport {WebSocketServer, WebSocket} from 'ws';\nimport {RequestResponse} from './models/RequestResponse';\nimport {getUrlMapping, getUrlMappings, SaveMappingConfig, UrlMappingSituationType} from './decorators/MethodMapping';\nimport {HttpStatus} from './codes/HttpStatus';\nimport {HttpHeaders} from './codes/HttpHeaders';\nimport {Mimes} from './codes/Mimes';\nimport {Filter} from './filters/Filter';\nimport {ExceptionHandlerSituationType, targetExceptionHandler} from '@dooboostore/simple-boot';\nimport {getInject, SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot';\nimport {EndPoint} from './endpoints/EndPoint';\nimport {ReflectUtils, ValidUtils} from '@dooboostore/core';\nimport {ReqFormUrlBody} from './models/datas/body/ReqFormUrlBody';\nimport {ReqJsonBody} from './models/datas/body/ReqJsonBody';\nimport {ReqHeader} from './models/datas/ReqHeader';\nimport {RouterModule} from '@dooboostore/simple-boot';\nimport {ReqMultipartFormBody} from './models/datas/body/ReqMultipartFormBody';\nimport {execValidationInValid, getValidIndex} from '@dooboostore/simple-boot';\nimport {ValidException} from '@dooboostore/simple-boot';\nimport {HttpError} from './errors/HttpError';\nimport {getRoute} from '@dooboostore/simple-boot';\nimport {OnInit} from './lifecycle/OnInit';\nimport {URLSearchParams} from 'url';\nimport {HttpMethod} from './codes/HttpMethod';\nimport {SessionManager} from './session/SessionManager';\nimport {InjectSituationType} from './inject/InjectSituationType';\nimport {ContentTypeGenerator} from './generators/ContentTypeGenerator';\nimport {ReqSearchParamsObj} from \"./models/datas/path/ReqSearchParamsObj\";\nimport {SimConfig} from '@dooboostore/simple-boot';\nimport {ReqPathData} from './models/datas/path/ReqPathData';\nimport {WebSocketEndPoint} from './endpoints/WebSocketEndPoint';\n\nexport class SimpleBootHttpServer extends SimpleApplication {\n public server?: HttpServer | HttpsServer;\n private sessionManager: SessionManager;\n private webSocketClients = new Map<WebSocket, { request: IncomingMessage }>();\n\n constructor(public option: HttpServerOption = new HttpServerOption()) {\n super(option);\n this.sessionManager = new SessionManager(this.option);\n }\n\n\n public run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>) {\n otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();\n otherInstanceSim.set(SimpleBootHttpServer, this);\n super.run(otherInstanceSim);\n const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...(this.option.filters ?? []).map(it=>it.filter)];\n Promise.all(targets.map(it => (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it as ConstructorType<any>}) : it) as OnInit).map(it => it.onInit(this))).then(it => {\n this.startServer();\n });\n return this;\n }\n\n private startServer() {\n\n // const a = this.option.serverOption as HttpsServerOption;\n // this.option.serverOption?.\n\n if (this.option.serverOption && 'key' in this.option.serverOption && 'cert' in this.option.serverOption) {\n this.server = new HttpsServer(this.option.serverOption);\n const httpServer = new HttpServer();\n httpServer.on('request', (req: IncomingMessage, res: ServerResponse) => {\n res.writeHead(301, {Location: `https://${req.headers.host}${req.url}`});\n res.end();\n });\n httpServer.listen(80, this.option.listen.hostname, () => {\n console.log('HTTP redirect server running on port 80');\n });\n } else if (this.option.serverOption) {\n this.server = new HttpServer(this.option.serverOption);\n } else {\n this.server = new HttpServer();\n }\n // const thisRef = this;\n this.server.on('request', async (req: IncomingMessage, res: ServerResponse) => {\n // console.log('request', req.url);\n const transactionManager = this.option.transactionManagerFactory ? await this.option.transactionManagerFactory() : undefined;\n res.on('close', async () => {\n if (this.option.closeEndPoints) {\n for (const it of this.option.closeEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it) as EndPoint;\n const endPoint = execute?.endPoint(rr, this);\n if (endPoint instanceof Promise) {\n await endPoint;\n }\n } catch (e) {\n }\n }\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n res.on('error', async () => {\n if (this.option.errorEndPoints) {\n for (const it of this.option.errorEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it) as EndPoint;\n const endPoint = execute?.endPoint(rr, this);\n if (endPoint instanceof Promise) {\n await endPoint;\n }\n } catch (e) {\n }\n }\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n\n const rr = new RequestResponse(req, res, {sessionManager: this.sessionManager, option: this.option});\n /*\n default setting first\n */\n rr.resSetHeader(HttpHeaders.Server, 'simple-boot-http-server');\n const cookie = rr.reqCookieGet(this.option.sessionOption.key);\n if (!cookie) {\n const session = await this.sessionManager.session();\n\n const cookieParts: string[] = [];\n cookieParts.push(`${this.option.sessionOption.key}=${session.uuid}`);\n cookieParts.push(`Path=${this.option.sessionOption.path}`);\n if (this.option.sessionOption.httpOnly) cookieParts.push('HttpOnly');\n if (this.option.sessionOption.secure) cookieParts.push('Secure');\n if (this.option.sessionOption.sameSite != null && this.option.sessionOption.sameSite) cookieParts.push(`SameSite=${this.option.sessionOption.sameSite}`);\n const maxAge = (this.option.sessionOption as any).maxAge ?? (this.sessionManager.sessionOption)?.maxAge;\n if (maxAge != null) cookieParts.push(`Max-Age=${maxAge}`);\n rr.resSetHeader(HttpHeaders.SetCookie, cookieParts.join('; '));\n }\n\n const otherStorage = new Map<ConstructorType<any>, any>();\n otherStorage.set(RequestResponse, rr);\n otherStorage.set(IncomingMessage, req);\n otherStorage.set(ServerResponse, res);\n // \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC751\uB2F5 \uC644\uB8CC \uC804\uC5D0 \uB04A\uC73C\uBA74 abort. \uD578\uB4E4\uB7EC\uB294 \uD30C\uB77C\uBBF8\uD130 \uD0C0\uC785 AbortSignal \uB85C \uC8FC\uC785\uBC1B\uC544\n // fetch/timers/events.once \uB4F1\uC5D0 \uB118\uAE30\uBA74 \uB300\uAE30 \uC911\uC774\uC5B4\uB3C4 \uBC14\uB85C \uD480\uB9B0\uB2E4 (\uC81C\uB108\uB808\uC774\uD130 \uC2A4\uD2B8\uB9BC\uC758 \uC774\uBCA4\uD2B8 \uB300\uAE30 \uB204\uC218 \uBC29\uC9C0)\n const abortController = new AbortController();\n res.once('close', () => {\n if (!res.writableFinished) abortController.abort();\n });\n otherStorage.set(AbortSignal, abortController.signal);\n try {\n transactionManager?.try();\n if (this.option.requestEndPoints) {\n for (const it of this.option.requestEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim<EndPoint>({target: it}) : it) as EndPoint;\n execute?.endPoint(rr, this);\n } catch (e) {\n }\n }\n }\n\n const filter = {\n carrier: new Map<string, any>(),\n filters: [] as { filter: Filter, sw: boolean }[]\n };\n for (let i = 0; this.option.filters && i < this.option.filters.length; i++) {\n const it = this.option.filters[i];\n\n let isSkip = false;\n if (typeof it.isSupport === 'boolean') {\n isSkip = !it.isSupport;\n } else if (typeof it.isSupport === 'object') {\n isSkip = !it.isSupport.test(rr.reqUrlPathName)\n } else if (typeof it.isSupport === 'function') {\n isSkip = !it.isSupport(rr);\n }\n if(isSkip) {\n continue;\n }\n\n let sw = true;\n const itFilter = it.filter;\n const execute = (typeof itFilter === 'function' ? this.simstanceManager.getOrNewSim({target: itFilter}) : itFilter) as Filter;\n if (execute?.proceedBefore) {\n sw = await execute.proceedBefore({rr, app: this, carrier: filter.carrier});\n filter.filters.push({filter: execute, sw});\n }\n if (!sw) {\n break;\n }\n }\n\n // body.. something..\n // \uB77C\uC6B0\uD130 \uC5C6\uC774 \uD544\uD130\uB9CC\uC73C\uB85C \uB3C4\uB294 \uC11C\uBC84(\uC608: SSR \uC804\uC6A9)\uBA74, \uC5B4\uB290 \uD544\uD130\uB3C4 \uCC98\uB9AC\uD558\uC9C0 \uC54A\uC740 \uC694\uCCAD\uC740 404 \uB85C \uB05D\uB0B8\uB2E4\n // (\uBE0C\uB77C\uC6B0\uC800\uAC00 \uC54C\uC544\uC11C \uBCF4\uB0B4\uB294 /favicon.ico, /.well-known/... \uAC19\uC740 \uAC83 \u2014 \uC608\uC804\uC5D4 'no router' \uC5D0\uB7EC\uB85C 500 + \uB85C\uADF8)\n if (!rr.resIsDone() && !this.option.rootRouter) {\n rr.resStatusCode(HttpStatus.NotFound);\n } else if (!rr.resIsDone()) {\n const routerModule = await super.routing(rr.reqIntent);\n otherStorage.set(RouterModule, routerModule);\n const moduleInstance = routerModule?.getModuleInstance?.();\n let methods: SaveMappingConfig[] = [];\n if (routerModule && moduleInstance) {\n // router \uD074\uB798\uC2A4 \uB0B4\uBD80\uC5D0\uC11C \uC120\uC5B8\uB41C Route\uC77C\uB54C\n if (routerModule.propertyKeys) {\n const map = routerModule.propertyKeys?.map((it: string | symbol) => {\n return {propertyKey: it, config: getUrlMapping(moduleInstance, it)} as SaveMappingConfig\n });\n methods.push(...(map ?? []));\n } else {\n methods.push(...(getUrlMappings(moduleInstance).filter(it => !getRoute(moduleInstance, it.propertyKey)) ?? []));\n }\n\n // options\uB85C \uC694\uCCAD\uC624\uBA74\uC740 allow\uB85C \uB123\uACE0 \uADF8\uB0E5 200\uCC98\uB9AC\uD574\uC57C\uB428.\n if (rr.reqMethod()?.toUpperCase() === HttpMethod.OPTIONS.toUpperCase()) {\n rr.resSetHeader(HttpHeaders.Allow, methods.map(it => it.config.method).join(', '));\n rr.resStatusCode(HttpStatus.Ok);\n }\n\n // method \uCC3E\uAE30\n methods = methods.filter(it => it && it.propertyKey && it.config && rr.reqMethod()?.toUpperCase() === it.config.method.toUpperCase());\n methods.sort((a, b) => {\n return ((b.config?.req?.contentType?.length ?? 0) + (b.config?.req?.accept?.length ?? 0)) - ((a.config?.req?.contentType?.length ?? 0) + (a.config?.req?.accept?.length ?? 0));\n });\n methods = methods\n .filter(it => it.config?.req?.contentType ? (!!it.config?.req?.contentType?.find(sit => rr.reqHasContentTypeHeader(sit))) : true)\n .filter(it => it.config?.req?.accept ? (!!it.config?.req?.accept?.find(sit => rr.reqHasAcceptHeader(sit))) : true);\n\n if (methods[0]) {\n const it = methods[0];\n const paramTypes = ReflectUtils.getParameterTypes(moduleInstance, it.propertyKey)\n const injects = getInject(moduleInstance, it.propertyKey);\n const validIndexs = getValidIndex(moduleInstance, it.propertyKey);\n if (injects) {\n const isPathData = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_PATH_DATA);\n const isJson = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_JSON_BODY);\n const isSearchParamsObj = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ);\n const isFormUrl = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_FORM_URL_BODY);\n // \uC6B0\uC120 \uB2E4\uC2DC \uC81C\uAC70\uD55C\uB2E4.. \uD2B8\uB79C\uC81D\uC158 \uC5B4\uB5BB\uAC8C \uD560\uC9C0 \uB2E4\uC2DC \uC0DD\uAC01\n // const isTransactionManager = injects.find(it => it.config?.situationType === InjectSituationType.TransactionManager);\n const siturationContainers = new SituationTypeContainers();\n if (isPathData) {\n let data = await routerModule.pathData\n if (isPathData.type) {\n data = Object.assign(new isPathData.type(), data);\n }\n if (validIndexs.includes(isPathData.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_PATH_DATA,\n data\n }));\n }\n if (isJson) {\n let data = await rr.reqBodyJsonData();\n if (data !== null && isJson.type) {\n data = Object.assign(new isJson.type(), data);\n }\n if (validIndexs.includes(isJson.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_JSON_BODY,\n data\n }));\n }\n if (isSearchParamsObj) {\n let data = rr.reqUrlSearchParamsObj\n if (validIndexs.includes(isSearchParamsObj.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ,\n data\n }));\n }\n if (isFormUrl) {\n let data = await rr.reqBodyFormUrlData()\n if (isFormUrl.type) {\n data = Object.assign(new isFormUrl.type(), data);\n }\n if (validIndexs.includes(isFormUrl.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({situationType: UrlMappingSituationType.REQ_FORM_URL_BODY, data}));\n }\n // \uD2B8\uB79C\uC81D\uC158 \uC6B0\uC120 \uC81C\uAC70 \uB098\uC911\uC5D0 \uC5B4\uB5BB\uAC8C \uAD6C\uD604\uD560\uC9C0 \uC0DD\uAC01..\n // if (isTransactionManager && isTransactionManager.type && transactionManager && transactionManager.hasTransaction(isTransactionManager.type)) {\n // let data = await transactionManager.getTransaction(isTransactionManager.type);\n // if (data) {\n // data = await data.try(isTransactionManager.config.argument);\n // siturationContainers.push(new SituationTypeContainer({situationType: InjectSituationType.TransactionManager, data, index: isTransactionManager.index}));\n // }\n // }\n if (siturationContainers.length) {\n otherStorage.set(SituationTypeContainers, siturationContainers);\n }\n }\n\n for (const paramType of paramTypes) {\n if (paramType === ReqFormUrlBody) {\n otherStorage.set(ReqFormUrlBody, await rr.reqBodyReqFormUrlBody())\n } else if (paramType === ReqPathData) {\n otherStorage.set(ReqPathData, routerModule.pathData)\n } else if (paramType === ReqJsonBody) {\n otherStorage.set(ReqJsonBody, await rr.reqBodyReqJsonBody())\n } else if (paramType === ReqSearchParamsObj) {\n otherStorage.set(ReqSearchParamsObj, rr.reqUrlSearchParamsObj)\n } else if (paramType === URLSearchParams) {\n otherStorage.set(URLSearchParams, rr.reqUrlSearchParams)\n } else if (paramType === ReqMultipartFormBody) {\n otherStorage.set(ReqMultipartFormBody, rr.reqBodyMultipartFormData())\n } else if (paramType === ReqHeader) {\n otherStorage.set(ReqHeader, rr.reqHeaderObj)\n }\n }\n\n // execute !!!\n let data = await this.simstanceManager.executeBindParameterSimPromise({\n target: moduleInstance,\n targetKey: it.propertyKey\n }, otherStorage);\n /*\n \uC5EC\uAE30\uC5D0\uC11C \uC815\uD574\uC9C4 \uD0C0\uC785 \uB9AC\uD134\uC5D0 \uB530\uB978 \uC870\uCE58\n ...\n */\n const resConfig = it.config?.res;\n if (resConfig === 'manual') {\n // \uD578\uB4E4\uB7EC\uAC00 ServerResponse\uB97C \uC9C1\uC811 \uC8FC\uC785\uBC1B\uC544 \uC2A4\uC2A4\uB85C write/end\uB97C \uC81C\uC5B4\uD55C\uB2E4 (\uC608: SSE \uC2A4\uD2B8\uB9AC\uBC0D)\n } else if (ValidUtils.isGenerator(data) || ValidUtils.isAsyncGenerator(data)) {\n // \uC81C\uB108\uB808\uC774\uD130 \uB9AC\uD134: \uD5E4\uB354 \uBA3C\uC800 \uBCF4\uB0B4\uACE0, yield \uB41C \uAC12\uC744 \uD558\uB098\uC529 \uBC14\uB85C body \uB85C \uD758\uB824\uBCF4\uB0B8\uB2E4 (\uC608: SSE)\n // ContentTypeGenerator.Stream \uC774\uBA74 Content-Type(boundary \uD3EC\uD568)\u00B7\uC555\uCD95 \uC5EC\uBD80\uB97C \uC2A4\uD2B8\uB9BC\uC774 \uC815\uD55C\uB2E4\n const stream = ContentTypeGenerator.isStream(data) ? data : undefined;\n const headers = resConfig?.header ?? {};\n const contentType = stream?.contentType ?? resConfig?.contentType;\n if (contentType) {\n headers[HttpHeaders.ContentType] = contentType;\n }\n rr.resSetHeaders(headers);\n rr.resSetStatusCode(resConfig?.status ?? HttpStatus.Ok);\n await rr.resStream(data, { compress: stream?.compress });\n } else {\n if (it.config?.resolver) {\n const execute = typeof it.config.resolver === 'function' ? this.simstanceManager.getOrNewSim({target: it.config.resolver}) : it.config.resolver;\n data = await execute?.resolve?.(data, rr, resConfig);\n }\n const status = resConfig?.status ?? HttpStatus.Ok;\n const headers = resConfig?.header ?? {};\n if (resConfig?.contentType) {\n headers[HttpHeaders.ContentType] = resConfig.contentType;\n }\n if ((resConfig?.contentType?.toLowerCase().indexOf(Mimes.ApplicationJson.toLowerCase()) ?? -1) > -1) {\n data = JSON.stringify(data);\n } else if (data && typeof data === 'object') {\n data = JSON.stringify(data);\n }\n rr.resSetHeaders(headers)\n rr.resSetStatusCode(status);\n rr.resWrite(data);\n }\n }\n }\n\n if (this.option.noSuchRouteEndPointMappingThrow && methods.length <= 0 && rr.reqMethod()?.toUpperCase() !== HttpMethod.OPTIONS) {\n throw this.option.noSuchRouteEndPointMappingThrow(rr);\n }\n }\n\n // after\n for (const it of filter.filters.reverse()) {\n if (it.filter?.proceedAfter && !await it.filter.proceedAfter({rr, app: this, before: it.sw, carrier: filter.carrier})) {\n break;\n }\n }\n } catch (e) {\n console.error('request error:', e);\n transactionManager?.catch(e);\n rr.resStatusCode(e instanceof HttpError ? e.status : HttpStatus.InternalServerError)\n const execute = typeof this.option.globalAdvice === 'function' ? this.simstanceManager.getOrNewSim(this.option.globalAdvice) : this.option.globalAdvice;\n if (!execute) {\n rr.resEnd();\n // rr.resEnd().catch(e => {\n // });\n return;\n }\n if (e && typeof e === 'object') {\n otherStorage.set(e.constructor as ConstructorType<any>, e);\n otherStorage.set(SituationTypeContainer, new SituationTypeContainer({\n situationType: ExceptionHandlerSituationType.ERROR_OBJECT,\n data: e\n }));\n }\n const target = targetExceptionHandler(execute, e);\n if (target) {\n await this.simstanceManager.executeBindParameterSimPromise({\n target: execute,\n targetKey: target.propertyKey\n }, otherStorage);\n }\n } finally {\n transactionManager?.finally();\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n\n if (this.option.webSocketEndPoints) {\n const webSocketServer = new WebSocketServer({server: this.server});\n const execute = this.option.webSocketEndPoints.map(it => typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it);\n webSocketServer.on('connection', async (ws, request) => {\n this.webSocketClients.set(ws, {request});\n const wsSet = {socket: ws, request};\n execute.forEach(it => it.connect?.(wsSet));\n ws.on('error', err => execute.forEach(it => it.error?.(wsSet, err)));\n ws.on('message', (data, isBinary) => execute.forEach(it => it.message(wsSet, {data, isBinary})));\n ws.on('ping', () => execute.forEach(it => it.ping?.(wsSet)));\n ws.on('close', () => {\n this.webSocketClients.delete(ws);\n execute.forEach(it => it.close?.(wsSet));\n });\n });\n }\n this.server.listen(this.option.listen.port, this.option.listen.hostname, this.option.listen.backlog, () => {\n this.option.listen.listeningListener?.(this, this.server);\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAQ,yBAAwB;AAChC,SAAQ,wBAAuB;AAE/B,SAAQ,iBAAiB,UAAU,YAAY,sBAAqB;AACpE,SAAQ,UAAU,mBAAkB;AACpC,SAAQ,uBAAiC;AACzC,SAAQ,uBAAsB;AAC9B,SAAQ,eAAe,gBAAmC,+BAA8B;AACxF,SAAQ,kBAAiB;AACzB,SAAQ,mBAAkB;AAC1B,SAAQ,aAAY;AAEpB,SAAQ,+BAA+B,8BAA6B;AACpE,SAAQ,WAAW,wBAAwB,+BAA8B;AAEzE,SAAQ,cAAc,kBAAiB;AACvC,SAAQ,sBAAqB;AAC7B,SAAQ,mBAAkB;AAC1B,SAAQ,iBAAgB;AACxB,SAAQ,oBAAmB;AAC3B,SAAQ,4BAA2B;AACnC,SAAQ,uBAAuB,qBAAoB;AACnD,SAAQ,sBAAqB;AAC7B,SAAQ,iBAAgB;AACxB,SAAQ,gBAAe;AAEvB,SAAQ,uBAAsB;AAC9B,SAAQ,kBAAiB;AACzB,SAAQ,sBAAqB;AAE7B,SAAQ,4BAA2B;AACnC,SAAQ,0BAAyB;AAEjC,SAAQ,mBAAkB;AAGnB,MAAM,6BAA6B,kBAAkB;AAAA,EAK1D,YAAmB,SAA2B,IAAI,iBAAiB,GAAG;AACpE,UAAM,MAAM;AADK;AAFnB,SAAQ,mBAAmB,oBAAI,IAA6C;AAI1E,SAAK,iBAAiB,IAAI,eAAe,KAAK,MAAM;AAAA,EACtD;AAAA,EAGO,IAAI,kBAAmF;AAC5F,yBAAqB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,SAAS,MAAM;AACzG,WAAK,OAAO,OAAO,oBAAoB,MAAM,KAAK,MAAM;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;",
|
|
4
|
+
"sourcesContent": ["import {SimpleApplication} from '@dooboostore/simple-boot';\nimport {HttpServerOption} from './option/HttpServerOption';\nimport {ConstructorType} from '@dooboostore/core';\nimport {IncomingMessage, Server as HttpServer, ServerResponse} from 'http'\nimport {Server as HttpsServer} from 'https'; // Add HTTPS support\nimport {WebSocketServer, WebSocket} from 'ws';\nimport {RequestResponse} from './models/RequestResponse';\nimport {getUrlMapping, getUrlMappings, SaveMappingConfig, UrlMappingSituationType} from './decorators/MethodMapping';\nimport {HttpStatus} from './codes/HttpStatus';\nimport {HttpHeaders} from './codes/HttpHeaders';\nimport {Mimes} from './codes/Mimes';\nimport {Filter} from './filters/Filter';\nimport {ExceptionHandlerSituationType, targetExceptionHandler} from '@dooboostore/simple-boot';\nimport {getInject, SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot';\nimport {EndPoint} from './endpoints/EndPoint';\nimport {ReflectUtils, ValidUtils} from '@dooboostore/core';\nimport {ReqFormUrlBody} from './models/datas/body/ReqFormUrlBody';\nimport {ReqJsonBody} from './models/datas/body/ReqJsonBody';\nimport {ReqHeader} from './models/datas/ReqHeader';\nimport {RouterModule} from '@dooboostore/simple-boot';\nimport {ReqMultipartFormBody} from './models/datas/body/ReqMultipartFormBody';\nimport {execValidationInValid, getValidIndex} from '@dooboostore/simple-boot';\nimport {ValidException} from '@dooboostore/simple-boot';\nimport {HttpError} from './errors/HttpError';\nimport {getRoute} from '@dooboostore/simple-boot';\nimport {OnInit} from './lifecycle/OnInit';\nimport {URLSearchParams} from 'url';\nimport {HttpMethod} from './codes/HttpMethod';\nimport {SessionManager} from './session/SessionManager';\nimport {InjectSituationType} from './inject/InjectSituationType';\nimport {ContentTypeGenerator} from './generators/ContentTypeGenerator';\nimport {ReqSearchParamsObj} from \"./models/datas/path/ReqSearchParamsObj\";\nimport {SimConfig} from '@dooboostore/simple-boot';\nimport {ReqPathData} from './models/datas/path/ReqPathData';\nimport {WebSocketEndPoint} from './endpoints/WebSocketEndPoint';\n\nexport class SimpleBootHttpServer extends SimpleApplication {\n public server?: HttpServer | HttpsServer;\n private sessionManager: SessionManager;\n private webSocketClients = new Map<WebSocket, { request: IncomingMessage }>();\n\n constructor(public option: HttpServerOption = new HttpServerOption()) {\n super(option);\n this.sessionManager = new SessionManager(this.option);\n }\n\n\n public run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>) {\n otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();\n otherInstanceSim.set(SimpleBootHttpServer, this);\n super.run(otherInstanceSim);\n const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...(this.option.filters ?? []).map(it=>it.filter)];\n Promise.all(targets.map(it => (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it as ConstructorType<any>}) : it) as OnInit).map(it => it.onInit(this))).then(it => {\n this.startServer();\n });\n return this;\n }\n\n private startServer() {\n\n // const a = this.option.serverOption as HttpsServerOption;\n // this.option.serverOption?.\n\n if (this.option.serverOption && 'key' in this.option.serverOption && 'cert' in this.option.serverOption) {\n this.server = new HttpsServer(this.option.serverOption);\n const httpServer = new HttpServer();\n httpServer.on('request', (req: IncomingMessage, res: ServerResponse) => {\n res.writeHead(301, {Location: `https://${req.headers.host}${req.url}`});\n res.end();\n });\n httpServer.listen(80, this.option.listen.hostname, () => {\n console.log('HTTP redirect server running on port 80');\n });\n } else if (this.option.serverOption) {\n this.server = new HttpServer(this.option.serverOption);\n } else {\n this.server = new HttpServer();\n }\n // const thisRef = this;\n this.server.on('request', async (req: IncomingMessage, res: ServerResponse) => {\n // console.log('request', req.url);\n const transactionManager = this.option.transactionManagerFactory ? await this.option.transactionManagerFactory() : undefined;\n res.on('close', async () => {\n if (this.option.closeEndPoints) {\n for (const it of this.option.closeEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it) as EndPoint;\n const endPoint = execute?.endPoint(rr, this);\n if (endPoint instanceof Promise) {\n await endPoint;\n }\n } catch (e) {\n }\n }\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n res.on('error', async () => {\n if (this.option.errorEndPoints) {\n for (const it of this.option.errorEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it) as EndPoint;\n const endPoint = execute?.endPoint(rr, this);\n if (endPoint instanceof Promise) {\n await endPoint;\n }\n } catch (e) {\n }\n }\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n\n const rr = new RequestResponse(req, res, {sessionManager: this.sessionManager, option: this.option});\n /*\n default setting first\n */\n rr.resSetHeader(HttpHeaders.Server, 'simple-boot-http-server');\n const cookie = rr.reqCookieGet(this.option.sessionOption.key);\n if (!cookie) {\n const session = await this.sessionManager.session();\n\n const cookieParts: string[] = [];\n cookieParts.push(`${this.option.sessionOption.key}=${session.uuid}`);\n cookieParts.push(`Path=${this.option.sessionOption.path}`);\n if (this.option.sessionOption.httpOnly) cookieParts.push('HttpOnly');\n if (this.option.sessionOption.secure) cookieParts.push('Secure');\n if (this.option.sessionOption.sameSite != null && this.option.sessionOption.sameSite) cookieParts.push(`SameSite=${this.option.sessionOption.sameSite}`);\n const maxAge = (this.option.sessionOption as any).maxAge ?? (this.sessionManager.sessionOption)?.maxAge;\n if (maxAge != null) cookieParts.push(`Max-Age=${maxAge}`);\n rr.resSetHeader(HttpHeaders.SetCookie, cookieParts.join('; '));\n }\n\n const otherStorage = new Map<ConstructorType<any>, any>();\n otherStorage.set(RequestResponse, rr);\n otherStorage.set(IncomingMessage, req);\n otherStorage.set(ServerResponse, res);\n // \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC751\uB2F5 \uC644\uB8CC \uC804\uC5D0 \uB04A\uC73C\uBA74 abort. \uD578\uB4E4\uB7EC\uB294 \uD30C\uB77C\uBBF8\uD130 \uD0C0\uC785 AbortSignal \uB85C \uC8FC\uC785\uBC1B\uC544\n // fetch/timers/events.once \uB4F1\uC5D0 \uB118\uAE30\uBA74 \uB300\uAE30 \uC911\uC774\uC5B4\uB3C4 \uBC14\uB85C \uD480\uB9B0\uB2E4 (\uC81C\uB108\uB808\uC774\uD130 \uC2A4\uD2B8\uB9BC\uC758 \uC774\uBCA4\uD2B8 \uB300\uAE30 \uB204\uC218 \uBC29\uC9C0)\n const abortController = new AbortController();\n res.once('close', () => {\n if (!res.writableFinished) abortController.abort();\n });\n otherStorage.set(AbortSignal, abortController.signal);\n try {\n transactionManager?.try();\n if (this.option.requestEndPoints) {\n for (const it of this.option.requestEndPoints) {\n try {\n const execute = (typeof it === 'function' ? this.simstanceManager.getOrNewSim<EndPoint>({target: it}) : it) as EndPoint;\n execute?.endPoint(rr, this);\n } catch (e) {\n }\n }\n }\n\n const filter = {\n carrier: new Map<string, any>(),\n filters: [] as { filter: Filter, sw: boolean }[]\n };\n for (let i = 0; this.option.filters && i < this.option.filters.length; i++) {\n const it = this.option.filters[i];\n\n let isSkip = false;\n if (typeof it.isSupport === 'boolean') {\n isSkip = !it.isSupport;\n } else if (typeof it.isSupport === 'object') {\n isSkip = !it.isSupport.test(rr.reqUrlPathName)\n } else if (typeof it.isSupport === 'function') {\n isSkip = !it.isSupport(rr);\n }\n if(isSkip) {\n continue;\n }\n\n let sw = true;\n const itFilter = it.filter;\n const execute = (typeof itFilter === 'function' ? this.simstanceManager.getOrNewSim({target: itFilter}) : itFilter) as Filter;\n if (execute?.proceedBefore) {\n sw = await execute.proceedBefore({rr, app: this, carrier: filter.carrier});\n filter.filters.push({filter: execute, sw});\n }\n if (!sw) {\n break;\n }\n }\n\n // body.. something..\n // \uB77C\uC6B0\uD130 \uC5C6\uC774 \uD544\uD130\uB9CC\uC73C\uB85C \uB3C4\uB294 \uC11C\uBC84(\uC608: SSR \uC804\uC6A9)\uBA74, \uC5B4\uB290 \uD544\uD130\uB3C4 \uCC98\uB9AC\uD558\uC9C0 \uC54A\uC740 \uC694\uCCAD\uC740 404 \uB85C \uB05D\uB0B8\uB2E4\n // (\uBE0C\uB77C\uC6B0\uC800\uAC00 \uC54C\uC544\uC11C \uBCF4\uB0B4\uB294 /favicon.ico, /.well-known/... \uAC19\uC740 \uAC83 \u2014 \uC608\uC804\uC5D4 'no router' \uC5D0\uB7EC\uB85C 500 + \uB85C\uADF8)\n if (!rr.resIsDone() && !this.option.rootRouter) {\n rr.resStatusCode(HttpStatus.NotFound);\n } else if (!rr.resIsDone()) {\n const routerModule = await super.routing(rr.reqIntent);\n otherStorage.set(RouterModule, routerModule);\n const moduleInstance = routerModule?.getModuleInstance?.();\n let methods: SaveMappingConfig[] = [];\n if (routerModule && moduleInstance) {\n // router \uD074\uB798\uC2A4 \uB0B4\uBD80\uC5D0\uC11C \uC120\uC5B8\uB41C Route\uC77C\uB54C\n if (routerModule.propertyKeys) {\n const map = routerModule.propertyKeys?.map((it: string | symbol) => {\n return {propertyKey: it, config: getUrlMapping(moduleInstance, it)} as SaveMappingConfig\n });\n methods.push(...(map ?? []));\n } else {\n methods.push(...(getUrlMappings(moduleInstance).filter(it => !getRoute(moduleInstance, it.propertyKey)) ?? []));\n }\n\n // options\uB85C \uC694\uCCAD\uC624\uBA74\uC740 allow\uB85C \uB123\uACE0 \uADF8\uB0E5 200\uCC98\uB9AC\uD574\uC57C\uB428.\n if (rr.reqMethod()?.toUpperCase() === HttpMethod.OPTIONS.toUpperCase()) {\n rr.resSetHeader(HttpHeaders.Allow, methods.map(it => it.config.method).join(', '));\n rr.resStatusCode(HttpStatus.Ok);\n }\n\n // method \uCC3E\uAE30\n methods = methods.filter(it => it && it.propertyKey && it.config && rr.reqMethod()?.toUpperCase() === it.config.method.toUpperCase());\n methods.sort((a, b) => {\n return ((b.config?.req?.contentType?.length ?? 0) + (b.config?.req?.accept?.length ?? 0)) - ((a.config?.req?.contentType?.length ?? 0) + (a.config?.req?.accept?.length ?? 0));\n });\n methods = methods\n .filter(it => it.config?.req?.contentType ? (!!it.config?.req?.contentType?.find(sit => rr.reqHasContentTypeHeader(sit))) : true)\n .filter(it => it.config?.req?.accept ? (!!it.config?.req?.accept?.find(sit => rr.reqHasAcceptHeader(sit))) : true);\n\n if (methods[0]) {\n const it = methods[0];\n const paramTypes = ReflectUtils.getParameterTypes(moduleInstance, it.propertyKey)\n const injects = getInject(moduleInstance, it.propertyKey);\n const validIndexs = getValidIndex(moduleInstance, it.propertyKey);\n if (injects) {\n const isPathData = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_PATH_DATA);\n const isJson = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_JSON_BODY);\n const isSearchParamsObj = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ);\n const isFormUrl = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_FORM_URL_BODY);\n // \uC6B0\uC120 \uB2E4\uC2DC \uC81C\uAC70\uD55C\uB2E4.. \uD2B8\uB79C\uC81D\uC158 \uC5B4\uB5BB\uAC8C \uD560\uC9C0 \uB2E4\uC2DC \uC0DD\uAC01\n // const isTransactionManager = injects.find(it => it.config?.situationType === InjectSituationType.TransactionManager);\n const siturationContainers = new SituationTypeContainers();\n if (isPathData) {\n let data = await routerModule.pathData\n if (isPathData.type) {\n data = Object.assign(new isPathData.type(), data);\n }\n if (validIndexs.includes(isPathData.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_PATH_DATA,\n data\n }));\n }\n if (isJson) {\n let data = await rr.reqBodyJsonData();\n if (data !== null && isJson.type) {\n data = Object.assign(new isJson.type(), data);\n }\n if (validIndexs.includes(isJson.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_JSON_BODY,\n data\n }));\n }\n if (isSearchParamsObj) {\n let data = rr.reqUrlSearchParamsObj\n if (validIndexs.includes(isSearchParamsObj.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({\n situationType: UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ,\n data\n }));\n }\n if (isFormUrl) {\n let data = await rr.reqBodyFormUrlData()\n if (isFormUrl.type) {\n data = Object.assign(new isFormUrl.type(), data);\n }\n if (validIndexs.includes(isFormUrl.index)) {\n const inValid = execValidationInValid(data);\n if ((inValid?.length ?? 0) > 0) {\n throw new ValidException(inValid);\n }\n }\n siturationContainers.push(new SituationTypeContainer({situationType: UrlMappingSituationType.REQ_FORM_URL_BODY, data}));\n }\n // \uD2B8\uB79C\uC81D\uC158 \uC6B0\uC120 \uC81C\uAC70 \uB098\uC911\uC5D0 \uC5B4\uB5BB\uAC8C \uAD6C\uD604\uD560\uC9C0 \uC0DD\uAC01..\n // if (isTransactionManager && isTransactionManager.type && transactionManager && transactionManager.hasTransaction(isTransactionManager.type)) {\n // let data = await transactionManager.getTransaction(isTransactionManager.type);\n // if (data) {\n // data = await data.try(isTransactionManager.config.argument);\n // siturationContainers.push(new SituationTypeContainer({situationType: InjectSituationType.TransactionManager, data, index: isTransactionManager.index}));\n // }\n // }\n if (siturationContainers.length) {\n otherStorage.set(SituationTypeContainers, siturationContainers);\n }\n }\n\n for (const paramType of paramTypes) {\n if (paramType === ReqFormUrlBody) {\n otherStorage.set(ReqFormUrlBody, await rr.reqBodyReqFormUrlBody())\n } else if (paramType === ReqPathData) {\n otherStorage.set(ReqPathData, routerModule.pathData)\n } else if (paramType === ReqJsonBody) {\n otherStorage.set(ReqJsonBody, await rr.reqBodyReqJsonBody())\n } else if (paramType === ReqSearchParamsObj) {\n otherStorage.set(ReqSearchParamsObj, rr.reqUrlSearchParamsObj)\n } else if (paramType === URLSearchParams) {\n otherStorage.set(URLSearchParams, rr.reqUrlSearchParams)\n } else if (paramType === ReqMultipartFormBody) {\n otherStorage.set(ReqMultipartFormBody, rr.reqBodyMultipartFormData())\n } else if (paramType === ReqHeader) {\n otherStorage.set(ReqHeader, rr.reqHeaderObj)\n }\n }\n\n // execute !!!\n let data = await this.simstanceManager.executeBindParameterSimPromise({\n target: moduleInstance,\n targetKey: it.propertyKey\n }, otherStorage);\n /*\n \uC5EC\uAE30\uC5D0\uC11C \uC815\uD574\uC9C4 \uD0C0\uC785 \uB9AC\uD134\uC5D0 \uB530\uB978 \uC870\uCE58\n ...\n */\n const resConfig = it.config?.res;\n if (resConfig === 'manual') {\n // \uD578\uB4E4\uB7EC\uAC00 ServerResponse\uB97C \uC9C1\uC811 \uC8FC\uC785\uBC1B\uC544 \uC2A4\uC2A4\uB85C write/end\uB97C \uC81C\uC5B4\uD55C\uB2E4 (\uC608: SSE \uC2A4\uD2B8\uB9AC\uBC0D)\n } else if (ValidUtils.isGenerator(data) || ValidUtils.isAsyncGenerator(data)) {\n // \uC81C\uB108\uB808\uC774\uD130 \uB9AC\uD134: \uD5E4\uB354 \uBA3C\uC800 \uBCF4\uB0B4\uACE0, yield \uB41C \uAC12\uC744 \uD558\uB098\uC529 \uBC14\uB85C body \uB85C \uD758\uB824\uBCF4\uB0B8\uB2E4 (\uC608: SSE)\n // ContentTypeGenerator.Stream \uC774\uBA74 Content-Type(boundary \uD3EC\uD568)\u00B7\uC555\uCD95 \uC5EC\uBD80\uB97C \uC2A4\uD2B8\uB9BC\uC774 \uC815\uD55C\uB2E4\n const stream = ContentTypeGenerator.isStream(data) ? data : undefined;\n const headers = resConfig?.header ?? {};\n const contentType = stream?.contentType ?? resConfig?.contentType;\n if (contentType) {\n headers[HttpHeaders.ContentType] = contentType;\n }\n rr.resSetHeaders(headers);\n rr.resSetStatusCode(resConfig?.status ?? HttpStatus.Ok);\n await rr.resStream(data, { compress: stream?.compress });\n } else {\n if (it.config?.resolver) {\n const execute = typeof it.config.resolver === 'function' ? this.simstanceManager.getOrNewSim({target: it.config.resolver}) : it.config.resolver;\n data = await execute?.resolve?.(data, rr, resConfig);\n }\n const status = resConfig?.status ?? HttpStatus.Ok;\n const headers = resConfig?.header ?? {};\n if (resConfig?.contentType) {\n headers[HttpHeaders.ContentType] = resConfig.contentType;\n }\n if ((resConfig?.contentType?.toLowerCase().indexOf(Mimes.ApplicationJson.toLowerCase()) ?? -1) > -1) {\n data = JSON.stringify(data);\n } else if (data && typeof data === 'object') {\n data = JSON.stringify(data);\n }\n rr.resSetHeaders(headers)\n rr.resSetStatusCode(status);\n rr.resWrite(data);\n }\n }\n }\n\n if (this.option.noSuchRouteEndPointMappingThrow && methods.length <= 0 && rr.reqMethod()?.toUpperCase() !== HttpMethod.OPTIONS) {\n throw this.option.noSuchRouteEndPointMappingThrow(rr);\n }\n }\n\n // after\n for (const it of filter.filters.reverse()) {\n if (it.filter?.proceedAfter && !await it.filter.proceedAfter({rr, app: this, before: it.sw, carrier: filter.carrier})) {\n break;\n }\n }\n } catch (e) {\n console.error('request error:', e);\n transactionManager?.catch(e);\n rr.resStatusCode(e instanceof HttpError ? e.status : HttpStatus.InternalServerError)\n const globalAdvice = this.option.globalAdvice;\n // getOrNewSim takes { target }; passing the class directly\n // destructures to undefined and silently disables globalAdvice.\n const execute = typeof globalAdvice === 'function' ? this.simstanceManager.getOrNewSim({ target: globalAdvice }) : globalAdvice;\n if (!execute) {\n rr.resEnd();\n // rr.resEnd().catch(e => {\n // });\n return;\n }\n if (e && typeof e === 'object') {\n otherStorage.set(e.constructor as ConstructorType<any>, e);\n otherStorage.set(SituationTypeContainer, new SituationTypeContainer({\n situationType: ExceptionHandlerSituationType.ERROR_OBJECT,\n data: e\n }));\n }\n const target = targetExceptionHandler(execute, e);\n if (target) {\n await this.simstanceManager.executeBindParameterSimPromise({\n target: execute,\n targetKey: target.propertyKey\n }, otherStorage);\n }\n } finally {\n transactionManager?.finally();\n }\n\n if (!rr.resIsDone()) {\n rr.resEnd();\n }\n });\n\n if (this.option.webSocketEndPoints) {\n const webSocketServer = new WebSocketServer({server: this.server});\n const execute = this.option.webSocketEndPoints.map(it => typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it}) : it);\n webSocketServer.on('connection', async (ws, request) => {\n this.webSocketClients.set(ws, {request});\n const wsSet = {socket: ws, request};\n execute.forEach(it => it.connect?.(wsSet));\n ws.on('error', err => execute.forEach(it => it.error?.(wsSet, err)));\n ws.on('message', (data, isBinary) => execute.forEach(it => it.message(wsSet, {data, isBinary})));\n ws.on('ping', () => execute.forEach(it => it.ping?.(wsSet)));\n ws.on('close', () => {\n this.webSocketClients.delete(ws);\n execute.forEach(it => it.close?.(wsSet));\n });\n });\n }\n this.server.listen(this.option.listen.port, this.option.listen.hostname, this.option.listen.backlog, () => {\n this.option.listen.listeningListener?.(this, this.server);\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAQ,yBAAwB;AAChC,SAAQ,wBAAuB;AAE/B,SAAQ,iBAAiB,UAAU,YAAY,sBAAqB;AACpE,SAAQ,UAAU,mBAAkB;AACpC,SAAQ,uBAAiC;AACzC,SAAQ,uBAAsB;AAC9B,SAAQ,eAAe,gBAAmC,+BAA8B;AACxF,SAAQ,kBAAiB;AACzB,SAAQ,mBAAkB;AAC1B,SAAQ,aAAY;AAEpB,SAAQ,+BAA+B,8BAA6B;AACpE,SAAQ,WAAW,wBAAwB,+BAA8B;AAEzE,SAAQ,cAAc,kBAAiB;AACvC,SAAQ,sBAAqB;AAC7B,SAAQ,mBAAkB;AAC1B,SAAQ,iBAAgB;AACxB,SAAQ,oBAAmB;AAC3B,SAAQ,4BAA2B;AACnC,SAAQ,uBAAuB,qBAAoB;AACnD,SAAQ,sBAAqB;AAC7B,SAAQ,iBAAgB;AACxB,SAAQ,gBAAe;AAEvB,SAAQ,uBAAsB;AAC9B,SAAQ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AC,CAAC,CAAC;AAC/F,WAAG,GAAG,QAAQ,MAAM,QAAQ,QAAQ,QAAM,GAAG,OAAO,KAAK,CAAC,CAAC;AAC3D,WAAG,GAAG,SAAS,MAAM;AACnB,eAAK,iBAAiB,OAAO,EAAE;AAC/B,kBAAQ,QAAQ,QAAM,GAAG,QAAQ,KAAK,CAAC;AAAA,QACzC,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AACA,SAAK,OAAO,OAAO,KAAK,OAAO,OAAO,MAAM,KAAK,OAAO,OAAO,UAAU,KAAK,OAAO,OAAO,SAAS,MAAM;AACzG,WAAK,OAAO,OAAO,oBAAoB,MAAM,KAAK,MAAM;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": ["it", "data"]
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ function GET(configOrTarget, propertyKey, descriptor) {
|
|
|
37
37
|
process({ method: HttpMethod.GET }, configOrTarget, propertyKey, descriptor);
|
|
38
38
|
} else {
|
|
39
39
|
return (target, propertyKey2, descriptor2) => {
|
|
40
|
+
configOrTarget = configOrTarget ?? {};
|
|
40
41
|
configOrTarget.method = HttpMethod.GET;
|
|
41
42
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
42
43
|
};
|
|
@@ -53,6 +54,7 @@ function POST(configOrTarget, propertyKey, descriptor) {
|
|
|
53
54
|
process({ method: HttpMethod.POST }, configOrTarget, propertyKey, descriptor);
|
|
54
55
|
} else {
|
|
55
56
|
return (target, propertyKey2, descriptor2) => {
|
|
57
|
+
configOrTarget = configOrTarget ?? {};
|
|
56
58
|
configOrTarget.method = HttpMethod.POST;
|
|
57
59
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
58
60
|
};
|
|
@@ -69,6 +71,7 @@ function DELETE(configOrTarget, propertyKey, descriptor) {
|
|
|
69
71
|
process({ method: HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor);
|
|
70
72
|
} else {
|
|
71
73
|
return (target, propertyKey2, descriptor2) => {
|
|
74
|
+
configOrTarget = configOrTarget ?? {};
|
|
72
75
|
configOrTarget.method = HttpMethod.DELETE;
|
|
73
76
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
74
77
|
};
|
|
@@ -85,6 +88,7 @@ function PUT(configOrTarget, propertyKey, descriptor) {
|
|
|
85
88
|
process({ method: HttpMethod.PUT }, configOrTarget, propertyKey, descriptor);
|
|
86
89
|
} else {
|
|
87
90
|
return (target, propertyKey2, descriptor2) => {
|
|
91
|
+
configOrTarget = configOrTarget ?? {};
|
|
88
92
|
configOrTarget.method = HttpMethod.PUT;
|
|
89
93
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
90
94
|
};
|
|
@@ -101,6 +105,7 @@ function PATCH(configOrTarget, propertyKey, descriptor) {
|
|
|
101
105
|
process({ method: HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor);
|
|
102
106
|
} else {
|
|
103
107
|
return (target, propertyKey2, descriptor2) => {
|
|
108
|
+
configOrTarget = configOrTarget ?? {};
|
|
104
109
|
configOrTarget.method = HttpMethod.PATCH;
|
|
105
110
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
106
111
|
};
|
|
@@ -117,6 +122,7 @@ function OPTIONS(configOrTarget, propertyKey, descriptor) {
|
|
|
117
122
|
process({ method: HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor);
|
|
118
123
|
} else {
|
|
119
124
|
return (target, propertyKey2, descriptor2) => {
|
|
125
|
+
configOrTarget = configOrTarget ?? {};
|
|
120
126
|
configOrTarget.method = HttpMethod.OPTIONS;
|
|
121
127
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
122
128
|
};
|
|
@@ -133,6 +139,7 @@ function HEAD(configOrTarget, propertyKey, descriptor) {
|
|
|
133
139
|
process({ method: HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor);
|
|
134
140
|
} else {
|
|
135
141
|
return (target, propertyKey2, descriptor2) => {
|
|
142
|
+
configOrTarget = configOrTarget ?? {};
|
|
136
143
|
configOrTarget.method = HttpMethod.HEAD;
|
|
137
144
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
138
145
|
};
|
|
@@ -149,6 +156,7 @@ function TRACE(configOrTarget, propertyKey, descriptor) {
|
|
|
149
156
|
process({ method: HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor);
|
|
150
157
|
} else {
|
|
151
158
|
return (target, propertyKey2, descriptor2) => {
|
|
159
|
+
configOrTarget = configOrTarget ?? {};
|
|
152
160
|
configOrTarget.method = HttpMethod.TRACE;
|
|
153
161
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
154
162
|
};
|
|
@@ -165,6 +173,7 @@ function CONNECT(configOrTarget, propertyKey, descriptor) {
|
|
|
165
173
|
process({ method: HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor);
|
|
166
174
|
} else {
|
|
167
175
|
return (target, propertyKey2, descriptor2) => {
|
|
176
|
+
configOrTarget = configOrTarget ?? {};
|
|
168
177
|
configOrTarget.method = HttpMethod.CONNECT;
|
|
169
178
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
170
179
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/MethodMapping.ts"],
|
|
4
|
-
"sourcesContent": ["import { ConstructorType } from '@dooboostore/core';\nimport { ReflectMethod } from '@dooboostore/simple-boot';\nimport { ReflectUtils } from '@dooboostore/core';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_PATH_DATA = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_PATH_DATA',\n // REQ_URL_SEARCH_PARAMS = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS',\n REQ_URL_SEARCH_PARAMS_OBJ = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS_OBJ',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type RequestMappingConfig = {\n method: HttpMethod | string;\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes | string)[];\n accept?: (Mimes | string)[];\n };\n};\nexport type ResponseMappingConfig = {\n status?: number;\n header?: { [key: string]: string };\n contentType?: Mimes | string;\n};\nexport type MappingConfig = (RequestMappingConfig & { res?: ResponseMappingConfig; resolver?: Resolver | ConstructorType<Resolver> }) | (RequestMappingConfig & { res: 'manual' });\nexport type SaveMappingConfig = { propertyKey: string | symbol; config: MappingConfig };\nconst MappingMetadataKey = Symbol.for('simple-boot-http-server:mapping-metadata');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({ propertyKey, config });\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n};\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.GET }, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n };\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n};\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n};\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.GET }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n};\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.POST }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n};\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n};\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.PUT }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n};\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PATCH);\n};\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n};\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.HEAD);\n};\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n};\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n};\n\n// Aliases for lowercase\nexport const urlMapping = UrlMapping;\nexport const getMethod = GET;\nexport const postMethod = POST;\nexport const patchMethod = PATCH;\nexport const putMethod = PUT;\nexport const deleteMethod = DELETE;\nexport const optionsMethod = OPTIONS;\nexport const headMethod = HEAD;\nexport const traceMethod = TRACE;\nexport const connectMethod = CONNECT;\n"],
|
|
5
|
-
"mappings": "AAEA,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAEpB,IAAK,0BAAL,kBAAKA,6BAAL;AACL,EAAAA,yBAAA,mBAAgB;AAChB,EAAAA,yBAAA,mBAAgB;AAEhB,EAAAA,yBAAA,+BAA4B;AAC5B,EAAAA,yBAAA,uBAAoB;AALV,SAAAA;AAAA,GAAA;AA0BZ,MAAM,qBAAqB,OAAO,IAAI,0CAA0C;AAIhF,MAAM,UAAU,CAAC,QAAuB,QAAa,aAA8B,eAAmC;AACpH,QAAM,qBAAsB,aAAa,YAAY,oBAAoB,OAAO,WAAW,KAAK,CAAC;AACjG,qBAAmB,KAAK,EAAE,aAAa,OAAO,CAAC;AAC/C,eAAa,eAAe,oBAAoB,oBAAoB,OAAO,WAAW;AACtF,eAAa,eAAe,oBAAoB,QAAQ,QAAQ,WAAW;AAC7E;AAGO,SAAS,WAAW,gBAAsC,aAA+B,YAAuD;AACrJ,MAAI,eAAe,YAAY;AAC7B,YAAQ,EAAE,QAAQ,WAAW,IAAI,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC7E,OAAO;AACL,WAAO,CAAC,QAAaC,cAA8BC,gBAAmC;AACpF,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IACzD;AAAA,EACF;AACF;AACO,MAAM,gBAAgB,CAAC,QAAa,gBAA4D;AACrG,S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Q,EAAE,QAAQ,WAAW,MAAM,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC/E,OAAO;AACL,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AACpF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IACzD;AAAA,EACF;AACF;AAEO,MAAM,WAAW,CAAC,QAAa,gBAA4D;AAChG,SAAO,cAAc,QAAQ,WAAW;AAC1C;AACO,MAAM,YAAY,CAAC,WAAqC;AAC7D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,KAAK;AAClG;AAGO,SAAS,QAAQ,gBAAsD,aAA+B,YAAuD;AAClK,MAAI,eAAe,YAAY;AAC7B,YAAQ,EAAE,QAAQ,WAAW,QAAQ,GAAG,gBAAgB,aAAa,UAAU;AAAA,EACjF,OAAO;AACL,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AACpF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IACzD;AAAA,EACF;AACF;AAEO,MAAM,aAAa,CAAC,QAAa,gBAA4D;AAClG,SAAO,cAAc,QAAQ,WAAW;AAC1C;AACO,MAAM,cAAc,CAAC,WAAqC;AAC/D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,OAAO;AACpG;AAGO,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,gBAAgB;",
|
|
4
|
+
"sourcesContent": ["import { ConstructorType } from '@dooboostore/core';\nimport { ReflectMethod } from '@dooboostore/simple-boot';\nimport { ReflectUtils } from '@dooboostore/core';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_PATH_DATA = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_PATH_DATA',\n // REQ_URL_SEARCH_PARAMS = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS',\n REQ_URL_SEARCH_PARAMS_OBJ = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS_OBJ',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type RequestMappingConfig = {\n method: HttpMethod | string;\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes | string)[];\n accept?: (Mimes | string)[];\n };\n};\nexport type ResponseMappingConfig = {\n status?: number;\n header?: { [key: string]: string };\n contentType?: Mimes | string;\n};\nexport type MappingConfig = (RequestMappingConfig & { res?: ResponseMappingConfig; resolver?: Resolver | ConstructorType<Resolver> }) | (RequestMappingConfig & { res: 'manual' });\nexport type SaveMappingConfig = { propertyKey: string | symbol; config: MappingConfig };\nconst MappingMetadataKey = Symbol.for('simple-boot-http-server:mapping-metadata');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({ propertyKey, config });\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n};\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.GET }, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n };\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n};\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n};\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.GET }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n};\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.POST }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n};\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n};\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.PUT }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n};\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PATCH);\n};\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n};\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.HEAD);\n};\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n};\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({ method: HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget = configOrTarget ?? {};\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n };\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n};\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n};\n\n// Aliases for lowercase\nexport const urlMapping = UrlMapping;\nexport const getMethod = GET;\nexport const postMethod = POST;\nexport const patchMethod = PATCH;\nexport const putMethod = PUT;\nexport const deleteMethod = DELETE;\nexport const optionsMethod = OPTIONS;\nexport const headMethod = HEAD;\nexport const traceMethod = TRACE;\nexport const connectMethod = CONNECT;\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAEpB,IAAK,0BAAL,kBAAKA,6BAAL;AACL,EAAAA,yBAAA,mBAAgB;AAChB,EAAAA,yBAAA,mBAAgB;AAEhB,EAAAA,yBAAA,+BAA4B;AAC5B,EAAAA,yBAAA,uBAAoB;AALV,SAAAA;AAAA,GAAA;AA0BZ,MAAM,qBAAqB,OAAO,IAAI,0CAA0C;AAIhF,MAAM,UAAU,CAAC,QAAuB,QAAa,aAA8B,eAAmC;AACpH,QAAM,qBAAsB,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Q,WAAW,QAAQ,GAAG,gBAAgB,aAAa,UAAU;AAAA,EACjF,OAAO;AACL,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AACpF,uBAAiB,kBAAkB,CAAC;AACpC,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IACzD;AAAA,EACF;AACF;AAEO,MAAM,aAAa,CAAC,QAAa,gBAA4D;AAClG,SAAO,cAAc,QAAQ,WAAW;AAC1C;AACO,MAAM,cAAc,CAAC,WAAqC;AAC/D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,OAAO;AACpG;AAGO,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,gBAAgB;",
|
|
6
6
|
"names": ["UrlMappingSituationType", "propertyKey", "descriptor"]
|
|
7
7
|
}
|
|
@@ -11,6 +11,7 @@ import { Blob } from "node:buffer";
|
|
|
11
11
|
import { FileUtils } from "@dooboostore/core-node";
|
|
12
12
|
import { ConvertUtils as CoreConvertUtils } from "@dooboostore/core";
|
|
13
13
|
import { ConvertUtils } from "@dooboostore/core-node";
|
|
14
|
+
import { BadRequestError } from "../errors/BadRequestError.js";
|
|
14
15
|
class RequestResponse {
|
|
15
16
|
constructor(req, res, config) {
|
|
16
17
|
// [아키텍트님의 정석] RequestResponse 객체 고유의 속성 저장소 (트랜잭션 생명주기)
|
|
@@ -269,7 +270,12 @@ class RequestResponse {
|
|
|
269
270
|
return data;
|
|
270
271
|
}
|
|
271
272
|
async reqBodyJsonData() {
|
|
272
|
-
|
|
273
|
+
const raw = await this.reqBodyStringData();
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(raw);
|
|
276
|
+
} catch (e) {
|
|
277
|
+
throw new BadRequestError({ message: `Invalid JSON body: ${e?.message ?? e}` });
|
|
278
|
+
}
|
|
273
279
|
}
|
|
274
280
|
async reqBodyFormUrlData() {
|
|
275
281
|
const data = await this.reqBodyStringData();
|
|
@@ -292,7 +298,14 @@ class RequestResponse {
|
|
|
292
298
|
}
|
|
293
299
|
async reqBodyReqJsonBody() {
|
|
294
300
|
const data = await this.reqBodyStringData();
|
|
295
|
-
|
|
301
|
+
if (!data) {
|
|
302
|
+
return Object.assign(new ReqJsonBody(), {});
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
return Object.assign(new ReqJsonBody(), JSON.parse(data));
|
|
306
|
+
} catch (e) {
|
|
307
|
+
throw new BadRequestError({ message: `Invalid JSON body: ${e?.message ?? e}` });
|
|
308
|
+
}
|
|
296
309
|
}
|
|
297
310
|
resBodyJsonData() {
|
|
298
311
|
const data = ConvertUtils.toString(this.resBodyData());
|