@dooboostore/simple-boot-http-server 1.0.30 → 1.0.32
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/README.md +58 -1
- package/dist/cjs/SimpleBootHttpServer.js +6 -3
- package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
- package/dist/cjs/codes/Mimes.js +2 -0
- package/dist/cjs/codes/Mimes.js.map +2 -2
- package/dist/cjs/generators/ContentTypeGenerator.js +320 -0
- package/dist/cjs/generators/ContentTypeGenerator.js.map +7 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/models/RequestResponse.js +18 -4
- 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 +6 -3
- package/dist/esm/SimpleBootHttpServer.js.map +2 -2
- package/dist/esm/codes/Mimes.js +2 -0
- package/dist/esm/codes/Mimes.js.map +2 -2
- package/dist/esm/generators/ContentTypeGenerator.js +287 -0
- package/dist/esm/generators/ContentTypeGenerator.js.map +7 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/models/RequestResponse.js +18 -4
- 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 +678 -5240
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
- package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/types/codes/Mimes.d.ts +2 -0
- package/dist/types/codes/Mimes.d.ts.map +1 -1
- package/dist/types/generators/ContentTypeGenerator.d.ts +172 -0
- package/dist/types/generators/ContentTypeGenerator.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/models/RequestResponse.d.ts +4 -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 +678 -5240
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/SimpleBootHttpServer.ts +7 -3
- package/src/codes/Mimes.ts +2 -0
- package/src/generators/ContentTypeGenerator.ts +431 -0
- package/src/index.ts +1 -0
- package/src/models/RequestResponse.ts +21 -4
- package/src/option/HttpServerOption.ts +8 -1
|
@@ -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 {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 const headers = resConfig?.header ?? {};\n if (resConfig?.contentType) {\n headers[HttpHeaders.ContentType] = resConfig.contentType;\n }\n rr.resSetHeaders(headers);\n rr.resSetStatusCode(resConfig?.status ?? HttpStatus.Ok);\n await rr.resStream(data);\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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AO,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;",
|
|
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,m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AACzC,WAAG,GAAG,SAAS,SAAO,QAAQ,QAAQ,QAAM,GAAG,QAAQ,OAAO,GAAG,CAAC,CAAC;AACnE,WAAG,GAAG,WAAW,CAAC,MAAM,aAAa,QAAQ,QAAQ,QAAM,GAAG,QAAQ,OAAO,EAAC,MAAM,SAAQ,CAAC,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
|
}
|
package/dist/esm/codes/Mimes.js
CHANGED
|
@@ -26,6 +26,8 @@ var Mimes = /* @__PURE__ */ ((Mimes2) => {
|
|
|
26
26
|
Mimes2["MultipartFormData"] = "multipart/form-data";
|
|
27
27
|
Mimes2["TextEventStream"] = "text/event-stream";
|
|
28
28
|
Mimes2["ApplicationXndjson"] = "application/x-ndjson";
|
|
29
|
+
Mimes2["ApplicationJsonSeq"] = "application/json-seq";
|
|
30
|
+
Mimes2["TextCsv"] = "text/csv";
|
|
29
31
|
Mimes2["ApplicationJsonPostSimpleBootSsrIntentScheme"] = "application/json-post+simple-boot-ssr-intent-scheme";
|
|
30
32
|
Mimes2["Intent"] = "intent";
|
|
31
33
|
return Mimes2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/codes/Mimes.ts"],
|
|
4
|
-
"sourcesContent": ["export enum Mimes {\n ApplicationJson = 'application/json',\n ApplicationOctetStream = 'application/octet-stream',\n ApplicationXml = 'application/xml',\n ApplicationJsonPatch = 'application/json-patch+json',\n ApplicationXWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n TextPlain = 'text/plain',\n TextHtml = 'text/html',\n All = '*/*',\n TextCss = 'text/css',\n TextJavascript = 'text/javascript',\n TextXml = 'text/xml',\n TextXslt = 'text/xslt',\n TextXmlDtd = 'text/xml-dtd',\n TextPlainUtf8 = 'text/plain; charset=utf-8',\n ImagePng = 'image/png',\n ImageGif = 'image/gif',\n ImageJpeg = 'image/jpeg',\n ImageSvg = 'image/svg+xml',\n ImageBmp = 'image/bmp',\n ImageTiff = 'image/tiff',\n ImagePdf = 'application/pdf',\n ImageXBmp = 'image/x-bmp',\n ImageXpixmap = 'image/x-xpixmap',\n ImageXxbm = 'image/x-xbm',\n MultipartFormData = 'multipart/form-data',\n TextEventStream = 'text/event-stream', // SSE \uC2E4\uC2DC\uAC04 \uD14D\uC2A4\uD2B8 \uC2A4\uD2B8\uB9AC\uBC0D\n ApplicationXndjson = 'application/x-ndjson',\n ApplicationJsonPostSimpleBootSsrIntentScheme = 'application/json-post+simple-boot-ssr-intent-scheme',\n Intent = 'intent'\n}\n"],
|
|
5
|
-
"mappings": "AAAO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,4BAAyB;AACzB,EAAAA,OAAA,oBAAiB;AACjB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,mCAAgC;AAChC,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,SAAM;AACN,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,oBAAiB;AACjB,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,kDAA+C;AAC/C,EAAAA,OAAA,YAAS;
|
|
4
|
+
"sourcesContent": ["export enum Mimes {\n ApplicationJson = 'application/json',\n ApplicationOctetStream = 'application/octet-stream',\n ApplicationXml = 'application/xml',\n ApplicationJsonPatch = 'application/json-patch+json',\n ApplicationXWwwFormUrlencoded = 'application/x-www-form-urlencoded',\n TextPlain = 'text/plain',\n TextHtml = 'text/html',\n All = '*/*',\n TextCss = 'text/css',\n TextJavascript = 'text/javascript',\n TextXml = 'text/xml',\n TextXslt = 'text/xslt',\n TextXmlDtd = 'text/xml-dtd',\n TextPlainUtf8 = 'text/plain; charset=utf-8',\n ImagePng = 'image/png',\n ImageGif = 'image/gif',\n ImageJpeg = 'image/jpeg',\n ImageSvg = 'image/svg+xml',\n ImageBmp = 'image/bmp',\n ImageTiff = 'image/tiff',\n ImagePdf = 'application/pdf',\n ImageXBmp = 'image/x-bmp',\n ImageXpixmap = 'image/x-xpixmap',\n ImageXxbm = 'image/x-xbm',\n MultipartFormData = 'multipart/form-data',\n TextEventStream = 'text/event-stream', // SSE \uC2E4\uC2DC\uAC04 \uD14D\uC2A4\uD2B8 \uC2A4\uD2B8\uB9AC\uBC0D\n ApplicationXndjson = 'application/x-ndjson',\n ApplicationJsonSeq = 'application/json-seq', // RFC 7464 JSON Text Sequences\n TextCsv = 'text/csv',\n ApplicationJsonPostSimpleBootSsrIntentScheme = 'application/json-post+simple-boot-ssr-intent-scheme',\n Intent = 'intent'\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAK,QAAL,kBAAKA,WAAL;AACL,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,4BAAyB;AACzB,EAAAA,OAAA,oBAAiB;AACjB,EAAAA,OAAA,0BAAuB;AACvB,EAAAA,OAAA,mCAAgC;AAChC,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,SAAM;AACN,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,oBAAiB;AACjB,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,gBAAa;AACb,EAAAA,OAAA,mBAAgB;AAChB,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,cAAW;AACX,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,kBAAe;AACf,EAAAA,OAAA,eAAY;AACZ,EAAAA,OAAA,uBAAoB;AACpB,EAAAA,OAAA,qBAAkB;AAClB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,wBAAqB;AACrB,EAAAA,OAAA,aAAU;AACV,EAAAA,OAAA,kDAA+C;AAC/C,EAAAA,OAAA,YAAS;AA/BC,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["Mimes"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { randomBytes } from "crypto";
|
|
2
|
+
import mime from "mime-types";
|
|
3
|
+
import { ValidUtils } from "@dooboostore/core";
|
|
4
|
+
import { Mimes } from "../codes/Mimes.js";
|
|
5
|
+
var ContentTypeGenerator;
|
|
6
|
+
((ContentTypeGenerator2) => {
|
|
7
|
+
ContentTypeGenerator2.isStream = (value) => ValidUtils.isAsyncGenerator(value) && typeof value.contentType === "string";
|
|
8
|
+
const oneLine = (v) => v.replace(/[\r\n]/g, " ");
|
|
9
|
+
ContentTypeGenerator2.sseChunk = (e) => {
|
|
10
|
+
const ev = typeof e === "string" ? { data: e } : e;
|
|
11
|
+
let out = "";
|
|
12
|
+
if (ev.comment !== void 0) out += ev.comment.split(/\r\n|\r|\n/).map((l) => `: ${l}
|
|
13
|
+
`).join("");
|
|
14
|
+
if (ev.event !== void 0) out += `event: ${oneLine(ev.event)}
|
|
15
|
+
`;
|
|
16
|
+
if (ev.id !== void 0) out += `id: ${oneLine(ev.id)}
|
|
17
|
+
`;
|
|
18
|
+
if (ev.retry !== void 0) out += `retry: ${Math.max(0, Math.floor(ev.retry))}
|
|
19
|
+
`;
|
|
20
|
+
if (ev.data !== void 0) {
|
|
21
|
+
const text2 = typeof ev.data === "string" ? ev.data : JSON.stringify(ev.data);
|
|
22
|
+
out += text2.split(/\r\n|\r|\n/).map((l) => `data: ${l}
|
|
23
|
+
`).join("");
|
|
24
|
+
}
|
|
25
|
+
return out + "\n";
|
|
26
|
+
};
|
|
27
|
+
ContentTypeGenerator2.ssePing = () => ": ping\n\n";
|
|
28
|
+
const sniff = (b) => {
|
|
29
|
+
if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) return Mimes.ImageJpeg;
|
|
30
|
+
if (b.length >= 8 && b.readUInt32BE(0) === 2303741511 && b.readUInt32BE(4) === 218765834) return Mimes.ImagePng;
|
|
31
|
+
if (b.length >= 6 && b.toString("ascii", 0, 4) === "GIF8") return Mimes.ImageGif;
|
|
32
|
+
if (b.length >= 12 && b.toString("ascii", 0, 4) === "RIFF" && b.toString("ascii", 8, 12) === "WEBP") return "image/webp";
|
|
33
|
+
return void 0;
|
|
34
|
+
};
|
|
35
|
+
ContentTypeGenerator2.partType = (part, fallback) => {
|
|
36
|
+
const p = isPartObject(part) ? part : { body: part };
|
|
37
|
+
if (p.type) return p.type;
|
|
38
|
+
if (p.name) {
|
|
39
|
+
const byName = mime.lookup(p.name);
|
|
40
|
+
if (byName) return mime.contentType(byName) || byName;
|
|
41
|
+
}
|
|
42
|
+
if (typeof p.body === "string") return fallback ?? Mimes.TextPlainUtf8;
|
|
43
|
+
return sniff(Buffer.from(p.body.buffer, p.body.byteOffset, p.body.byteLength)) ?? fallback ?? Mimes.ApplicationOctetStream;
|
|
44
|
+
};
|
|
45
|
+
const isPartObject = (part) => typeof part === "object" && !(part instanceof Uint8Array);
|
|
46
|
+
const toBuffer = (body) => typeof body === "string" ? Buffer.from(body, "utf8") : Buffer.isBuffer(body) ? body : Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
47
|
+
ContentTypeGenerator2.multipartPart = (part, boundary2, fallbackType) => {
|
|
48
|
+
const p = isPartObject(part) ? part : { body: part };
|
|
49
|
+
const body = toBuffer(p.body);
|
|
50
|
+
let head = `--${boundary2}\r
|
|
51
|
+
Content-Type: ${(0, ContentTypeGenerator2.partType)(part, fallbackType)}\r
|
|
52
|
+
Content-Length: ${body.length}\r
|
|
53
|
+
`;
|
|
54
|
+
for (const [k, v] of Object.entries(p.headers ?? {})) head += `${oneLine(k)}: ${oneLine(v)}\r
|
|
55
|
+
`;
|
|
56
|
+
return Buffer.concat([Buffer.from(head + "\r\n", "latin1"), body, Buffer.from("\r\n")]);
|
|
57
|
+
};
|
|
58
|
+
ContentTypeGenerator2.multipartEnd = (boundary2) => Buffer.from(`--${boundary2}--\r
|
|
59
|
+
`);
|
|
60
|
+
ContentTypeGenerator2.ndjsonLine = (value) => json(value) + "\n";
|
|
61
|
+
const json = (value) => JSON.stringify(value) ?? "null";
|
|
62
|
+
ContentTypeGenerator2.jsonSeqRecord = (value) => "" + json(value) + "\n";
|
|
63
|
+
ContentTypeGenerator2.csvCell = (value) => {
|
|
64
|
+
if (value === null || value === void 0) return "";
|
|
65
|
+
const s = typeof value === "string" ? value : value instanceof Date ? value.toISOString() : typeof value === "object" ? json(value) : String(value);
|
|
66
|
+
return /[",\r\n]|^\s|\s$/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
67
|
+
};
|
|
68
|
+
ContentTypeGenerator2.csvRow = (cells) => cells.map(ContentTypeGenerator2.csvCell).join(",") + "\r\n";
|
|
69
|
+
ContentTypeGenerator2.textLine = (value) => (typeof value === "string" ? value : json(value)) + "\n";
|
|
70
|
+
ContentTypeGenerator2.boundary = (value) => {
|
|
71
|
+
const b = value ?? `boundary-${randomBytes(12).toString("hex")}`;
|
|
72
|
+
if (!/^[0-9A-Za-z'()+_,\-./:=? ]{0,69}[0-9A-Za-z'()+_,\-./:=?]$/.test(b)) {
|
|
73
|
+
throw new Error(`invalid multipart boundary: ${JSON.stringify(b)}`);
|
|
74
|
+
}
|
|
75
|
+
return b;
|
|
76
|
+
};
|
|
77
|
+
const toStream = (gen, contentType, compress) => Object.assign(gen, { contentType, compress });
|
|
78
|
+
async function* encode(src, fn) {
|
|
79
|
+
for await (const v of src) yield fn(v);
|
|
80
|
+
}
|
|
81
|
+
async function* framed(src, fn, start, end) {
|
|
82
|
+
if (start !== void 0) yield start;
|
|
83
|
+
yield* encode(src, fn);
|
|
84
|
+
if (end !== void 0) yield end;
|
|
85
|
+
}
|
|
86
|
+
const jsonArrayItem = () => {
|
|
87
|
+
let n = 0;
|
|
88
|
+
return (v) => (n++ ? "," : "") + json(v);
|
|
89
|
+
};
|
|
90
|
+
const csvEncoder = (opt) => (r) => (0, ContentTypeGenerator2.csvRow)(Array.isArray(r) ? r : opt.columns ? opt.columns.map((c) => r[c]) : Object.values(r));
|
|
91
|
+
const csvStart = (opt) => opt.bom || opt.columns ? (opt.bom ? "\uFEFF" : "") + (opt.columns ? (0, ContentTypeGenerator2.csvRow)(opt.columns) : "") : void 0;
|
|
92
|
+
const CsvType = `${Mimes.TextCsv}; charset=utf-8`;
|
|
93
|
+
function sse(src, opt = {}) {
|
|
94
|
+
const contentType = Mimes.TextEventStream;
|
|
95
|
+
if (!opt.heartbeatMs) return toStream(encode(src, ContentTypeGenerator2.sseChunk), contentType, true);
|
|
96
|
+
const ms = opt.heartbeatMs;
|
|
97
|
+
async function* withPing() {
|
|
98
|
+
const it = Symbol.asyncIterator in src ? src[Symbol.asyncIterator]() : src[Symbol.iterator]();
|
|
99
|
+
let pending;
|
|
100
|
+
try {
|
|
101
|
+
while (true) {
|
|
102
|
+
pending ??= Promise.resolve(it.next());
|
|
103
|
+
let timer;
|
|
104
|
+
const tick = new Promise((r2) => timer = setTimeout(() => r2("ping"), ms));
|
|
105
|
+
const r = await Promise.race([pending, tick]);
|
|
106
|
+
clearTimeout(timer);
|
|
107
|
+
if (r === "ping") {
|
|
108
|
+
yield (0, ContentTypeGenerator2.ssePing)();
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
pending = void 0;
|
|
112
|
+
if (r.done) return;
|
|
113
|
+
yield (0, ContentTypeGenerator2.sseChunk)(r.value);
|
|
114
|
+
}
|
|
115
|
+
} finally {
|
|
116
|
+
await it.return?.();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return toStream(withPing(), contentType, true);
|
|
120
|
+
}
|
|
121
|
+
ContentTypeGenerator2.sse = sse;
|
|
122
|
+
function multipartReplace(src, opt = {}) {
|
|
123
|
+
const b = (0, ContentTypeGenerator2.boundary)(opt.boundary);
|
|
124
|
+
return toStream(encode(src, (p) => (0, ContentTypeGenerator2.multipartPart)(p, b, opt.type)), `multipart/x-mixed-replace; boundary=${b}`, false);
|
|
125
|
+
}
|
|
126
|
+
ContentTypeGenerator2.multipartReplace = multipartReplace;
|
|
127
|
+
function multipartMixed(src, opt = {}) {
|
|
128
|
+
const b = (0, ContentTypeGenerator2.boundary)(opt.boundary);
|
|
129
|
+
return toStream(framed(src, (p) => (0, ContentTypeGenerator2.multipartPart)(p, b, opt.type), void 0, (0, ContentTypeGenerator2.multipartEnd)(b)), `multipart/mixed; boundary=${b}`, true);
|
|
130
|
+
}
|
|
131
|
+
ContentTypeGenerator2.multipartMixed = multipartMixed;
|
|
132
|
+
function ndjson(src) {
|
|
133
|
+
return toStream(encode(src, ContentTypeGenerator2.ndjsonLine), Mimes.ApplicationXndjson, true);
|
|
134
|
+
}
|
|
135
|
+
ContentTypeGenerator2.ndjson = ndjson;
|
|
136
|
+
function jsonSeq(src) {
|
|
137
|
+
return toStream(encode(src, ContentTypeGenerator2.jsonSeqRecord), Mimes.ApplicationJsonSeq, true);
|
|
138
|
+
}
|
|
139
|
+
ContentTypeGenerator2.jsonSeq = jsonSeq;
|
|
140
|
+
function jsonArray(src) {
|
|
141
|
+
return toStream(framed(src, jsonArrayItem(), "[", "]"), Mimes.ApplicationJson, true);
|
|
142
|
+
}
|
|
143
|
+
ContentTypeGenerator2.jsonArray = jsonArray;
|
|
144
|
+
function csv(src, opt = {}) {
|
|
145
|
+
return toStream(framed(src, csvEncoder(opt), csvStart(opt)), CsvType, true);
|
|
146
|
+
}
|
|
147
|
+
ContentTypeGenerator2.csv = csv;
|
|
148
|
+
function text(src) {
|
|
149
|
+
return toStream(encode(src, ContentTypeGenerator2.textLine), Mimes.TextPlainUtf8, true);
|
|
150
|
+
}
|
|
151
|
+
ContentTypeGenerator2.text = text;
|
|
152
|
+
function channel(encodeFn, contentType, compress, opt = {}) {
|
|
153
|
+
const keep = opt.keep ?? "queue";
|
|
154
|
+
const max = Math.max(1, opt.max ?? 1e3);
|
|
155
|
+
const queue = [];
|
|
156
|
+
const closers = [];
|
|
157
|
+
let closed = false;
|
|
158
|
+
let finished = false;
|
|
159
|
+
let startSent = false;
|
|
160
|
+
let endSent = false;
|
|
161
|
+
let wake;
|
|
162
|
+
const finish = () => {
|
|
163
|
+
if (finished) return;
|
|
164
|
+
finished = closed = true;
|
|
165
|
+
queue.length = 0;
|
|
166
|
+
opt.signal?.removeEventListener("abort", onAbort);
|
|
167
|
+
wake?.();
|
|
168
|
+
for (const fn of closers.splice(0)) {
|
|
169
|
+
try {
|
|
170
|
+
fn();
|
|
171
|
+
} catch {
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const onAbort = () => finish();
|
|
176
|
+
if (opt.signal?.aborted) closed = finished = true;
|
|
177
|
+
else opt.signal?.addEventListener("abort", onAbort, { once: true });
|
|
178
|
+
const next = async () => {
|
|
179
|
+
while (!finished) {
|
|
180
|
+
if (opt.start && !startSent) {
|
|
181
|
+
startSent = true;
|
|
182
|
+
return { value: opt.start(), done: false };
|
|
183
|
+
}
|
|
184
|
+
if (queue.length) return { value: encodeFn(queue.shift()), done: false };
|
|
185
|
+
if (closed) {
|
|
186
|
+
if (opt.end && !endSent) {
|
|
187
|
+
endSent = true;
|
|
188
|
+
return { value: opt.end(), done: false };
|
|
189
|
+
}
|
|
190
|
+
finish();
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
let timer;
|
|
194
|
+
const ping = await new Promise((resolve) => {
|
|
195
|
+
wake = () => resolve(false);
|
|
196
|
+
if (opt.heartbeat) timer = setTimeout(() => resolve(true), opt.heartbeat.ms);
|
|
197
|
+
});
|
|
198
|
+
wake = void 0;
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
if (ping && !finished && !queue.length && !closed) return { value: opt.heartbeat.chunk(), done: false };
|
|
201
|
+
}
|
|
202
|
+
return { value: void 0, done: true };
|
|
203
|
+
};
|
|
204
|
+
const iterator = {
|
|
205
|
+
contentType,
|
|
206
|
+
compress,
|
|
207
|
+
get closed() {
|
|
208
|
+
return closed;
|
|
209
|
+
},
|
|
210
|
+
push(value) {
|
|
211
|
+
if (closed) return false;
|
|
212
|
+
if (keep === "latest") queue.length = 0;
|
|
213
|
+
else if (queue.length >= max) queue.shift();
|
|
214
|
+
queue.push(value);
|
|
215
|
+
wake?.();
|
|
216
|
+
return true;
|
|
217
|
+
},
|
|
218
|
+
close() {
|
|
219
|
+
closed = true;
|
|
220
|
+
wake?.();
|
|
221
|
+
},
|
|
222
|
+
onClose(fn) {
|
|
223
|
+
if (finished) fn();
|
|
224
|
+
else closers.push(fn);
|
|
225
|
+
},
|
|
226
|
+
next,
|
|
227
|
+
async return() {
|
|
228
|
+
finish();
|
|
229
|
+
return { value: void 0, done: true };
|
|
230
|
+
},
|
|
231
|
+
async throw(e) {
|
|
232
|
+
finish();
|
|
233
|
+
throw e;
|
|
234
|
+
},
|
|
235
|
+
[Symbol.asyncIterator]() {
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const dispose = Symbol.asyncDispose;
|
|
240
|
+
if (dispose) iterator[dispose] = async () => finish();
|
|
241
|
+
return iterator;
|
|
242
|
+
}
|
|
243
|
+
ContentTypeGenerator2.channel = channel;
|
|
244
|
+
((sse2) => {
|
|
245
|
+
sse2.channel = (opt = {}) => ContentTypeGenerator2.channel(ContentTypeGenerator2.sseChunk, Mimes.TextEventStream, true, {
|
|
246
|
+
...opt,
|
|
247
|
+
heartbeat: opt.heartbeatMs ? { ms: opt.heartbeatMs, chunk: ContentTypeGenerator2.ssePing } : void 0
|
|
248
|
+
});
|
|
249
|
+
})(sse = ContentTypeGenerator2.sse || (ContentTypeGenerator2.sse = {}));
|
|
250
|
+
((multipartReplace2) => {
|
|
251
|
+
multipartReplace2.channel = (opt = {}) => {
|
|
252
|
+
const b = (0, ContentTypeGenerator2.boundary)(opt.boundary);
|
|
253
|
+
return ContentTypeGenerator2.channel((p) => (0, ContentTypeGenerator2.multipartPart)(p, b, opt.type), `multipart/x-mixed-replace; boundary=${b}`, false, opt);
|
|
254
|
+
};
|
|
255
|
+
})(multipartReplace = ContentTypeGenerator2.multipartReplace || (ContentTypeGenerator2.multipartReplace = {}));
|
|
256
|
+
((multipartMixed2) => {
|
|
257
|
+
multipartMixed2.channel = (opt = {}) => {
|
|
258
|
+
const b = (0, ContentTypeGenerator2.boundary)(opt.boundary);
|
|
259
|
+
return ContentTypeGenerator2.channel((p) => (0, ContentTypeGenerator2.multipartPart)(p, b, opt.type), `multipart/mixed; boundary=${b}`, true, {
|
|
260
|
+
...opt,
|
|
261
|
+
end: () => (0, ContentTypeGenerator2.multipartEnd)(b)
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
})(multipartMixed = ContentTypeGenerator2.multipartMixed || (ContentTypeGenerator2.multipartMixed = {}));
|
|
265
|
+
((ndjson2) => {
|
|
266
|
+
ndjson2.channel = (opt = {}) => ContentTypeGenerator2.channel(ContentTypeGenerator2.ndjsonLine, Mimes.ApplicationXndjson, true, opt);
|
|
267
|
+
})(ndjson = ContentTypeGenerator2.ndjson || (ContentTypeGenerator2.ndjson = {}));
|
|
268
|
+
((jsonSeq2) => {
|
|
269
|
+
jsonSeq2.channel = (opt = {}) => ContentTypeGenerator2.channel(ContentTypeGenerator2.jsonSeqRecord, Mimes.ApplicationJsonSeq, true, opt);
|
|
270
|
+
})(jsonSeq = ContentTypeGenerator2.jsonSeq || (ContentTypeGenerator2.jsonSeq = {}));
|
|
271
|
+
((jsonArray2) => {
|
|
272
|
+
jsonArray2.channel = (opt = {}) => ContentTypeGenerator2.channel(jsonArrayItem(), Mimes.ApplicationJson, true, { ...opt, start: () => "[", end: () => "]" });
|
|
273
|
+
})(jsonArray = ContentTypeGenerator2.jsonArray || (ContentTypeGenerator2.jsonArray = {}));
|
|
274
|
+
((csv2) => {
|
|
275
|
+
csv2.channel = (opt = {}) => {
|
|
276
|
+
const start = csvStart(opt);
|
|
277
|
+
return ContentTypeGenerator2.channel(csvEncoder(opt), CsvType, true, { ...opt, start: start === void 0 ? void 0 : () => start });
|
|
278
|
+
};
|
|
279
|
+
})(csv = ContentTypeGenerator2.csv || (ContentTypeGenerator2.csv = {}));
|
|
280
|
+
((text2) => {
|
|
281
|
+
text2.channel = (opt = {}) => ContentTypeGenerator2.channel(ContentTypeGenerator2.textLine, Mimes.TextPlainUtf8, true, opt);
|
|
282
|
+
})(text = ContentTypeGenerator2.text || (ContentTypeGenerator2.text = {}));
|
|
283
|
+
})(ContentTypeGenerator || (ContentTypeGenerator = {}));
|
|
284
|
+
export {
|
|
285
|
+
ContentTypeGenerator
|
|
286
|
+
};
|
|
287
|
+
//# sourceMappingURL=ContentTypeGenerator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/generators/ContentTypeGenerator.ts"],
|
|
4
|
+
"sourcesContent": ["import { randomBytes } from 'crypto';\nimport mime from 'mime-types';\nimport { ValidUtils } from '@dooboostore/core';\nimport { Mimes } from '../codes/Mimes';\n\n/**\n * Content-Type \uBCC4 \uC2A4\uD2B8\uB9AC\uBC0D \uC751\uB2F5 \uBB36\uC74C.\n * \uD578\uB4E4\uB7EC\uB294 \uB0B4\uC6A9(payload)\uB9CC \uB118\uAE30\uACE0, \uD615\uC2DD(SSE `data:`\u00B7multipart boundary\u00B7CRLF\u00B7Content-Type\u00B7Content-Length\u00B7NDJSON \uC904\uBC14\uAFC8)\uC740 \uC5EC\uAE30\uC11C \uBD99\uC778\uB2E4.\n *\n * \uB3CC\uB824\uC8FC\uB294 Stream \uC740 \uADF8\uB300\uB85C async generator \uB77C\uC11C \uD578\uB4E4\uB7EC\uC5D0\uC11C return \uD558\uBA74 \uD504\uB808\uC784\uC6CC\uD06C\uAC00 yield \uB9C8\uB2E4 \uBC14\uB85C body \uB85C \uC3DC\uB2E4.\n * Stream \uC774 contentType(boundary \uD3EC\uD568)\u00B7compress \uB97C \uB4E4\uACE0 \uC788\uC5B4 \uB370\uCF54\uB808\uC774\uD130\uC5D0 contentType \uC744 \uB530\uB85C \uC801\uC9C0 \uC54A\uC544\uB3C4 \uB41C\uB2E4.\n *\n * pull \u2014 \uB0B4 \uBC18\uBCF5\uBB38\uC774 \uB9CC\uB4E4\uC5B4 yield \uD560 \uB54C:\n * return ContentTypeGenerator.multipartReplace(this.frames(file, signal));\n * push \u2014 \uCF5C\uBC31\u00B7\uC774\uBCA4\uD2B8\uB85C \uC62C \uB54C\uB9C8\uB2E4 \uB123\uC744 \uB54C:\n * const out = ContentTypeGenerator.multipartReplace.channel({ signal, keep: 'latest' });\n * watcher.on('change', buf => out.push(buf));\n * out.onClose(() => watcher.close());\n * return out;\n */\nexport namespace ContentTypeGenerator {\n export type Source<T> = Iterable<T> | AsyncIterable<T>;\n\n /** \uD504\uB808\uC784\uC6CC\uD06C\uAC00 \uBC1B\uB294 \uC2A4\uD2B8\uB9BC: async generator + \uC751\uB2F5 \uD5E4\uB354 \uC815\uBCF4 */\n export type Stream<T = string | Buffer> = AsyncGenerator<T, void, undefined> & {\n readonly contentType: string;\n /** false \uBA74 Accept-Encoding: gzip \uC774\uC5B4\uB3C4 \uC555\uCD95 \uC548 \uD568 (JPEG \uCC98\uB7FC \uC774\uBBF8 \uC555\uCD95\uB41C \uB0B4\uC6A9) */\n readonly compress: boolean;\n };\n\n /** push \uC6A9: Stream + \uB123\uAE30\u00B7\uB2EB\uAE30 */\n export type Channel<In, Out = string | Buffer> = Stream<Out> & {\n /** \uB123\uAE30. \uB2EB\uD614\uC73C\uBA74 false */\n push(value: In): boolean;\n /** \uB354 \uB123\uC744 \uAC8C \uC5C6\uC74C \u2014 \uC313\uC778 \uAC74 \uB9C8\uC800 \uBCF4\uB0B4\uACE0 \uB05D\uB0C4 */\n close(): void;\n readonly closed: boolean;\n /** \uB05D\uB0A0 \uB54C(\uD074\uB77C\uC774\uC5B8\uD2B8 \uB04A\uAE40\u00B7close\u00B7signal abort) \uD55C \uBC88 \u2014 \uAC10\uC2DC\uC790\u00B7\uB9AC\uC2A4\uB108 \uC815\uB9AC\uC6A9 */\n onClose(fn: () => void): void;\n };\n\n export type ChannelOption = {\n /** abort \uB418\uBA74 \uCC44\uB110\uC744 \uB2EB\uC74C */\n signal?: AbortSignal;\n /** 'queue': \uD558\uB098\uB3C4 \uC548 \uBC84\uB9AC\uACE0 \uC21C\uC11C\uB300\uB85C (\uC774\uBCA4\uD2B8) \u00B7 'latest': \uBC00\uB9AC\uBA74 \uCD5C\uC2E0 \uD558\uB098\uB9CC (\uC601\uC0C1 \uD504\uB808\uC784) */\n keep?: 'queue' | 'latest';\n /** 'queue' \uCD5C\uB300 \uAC1C\uC218 \u2014 \uB118\uCE58\uBA74 \uAC00\uC7A5 \uC624\uB798\uB41C \uAC83\uBD80\uD130 \uBC84\uB9BC (\uAE30\uBCF8 1000) */\n max?: number;\n };\n\n export const isStream = (value: any): value is Stream =>\n ValidUtils.isAsyncGenerator(value) && typeof (value as any).contentType === 'string';\n\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \uD615\uC2DD \uADDC\uCE59 (\uC21C\uC218 \uD568\uC218) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n export type SseEvent =\n | string\n | { data?: unknown; event?: string; id?: string; retry?: number; comment?: string };\n\n const oneLine = (v: string) => v.replace(/[\\r\\n]/g, ' ');\n\n /**\n * SSE \uC774\uBCA4\uD2B8 \uD558\uB098 \u2192 `field: value\\n` \uC904\uB4E4 + \uBE48 \uC904(\\n).\n * data \uAC00 \uC5EC\uB7EC \uC904\uC774\uBA74 \uC904\uB9C8\uB2E4 `data: ` (\uADF8\uB0E5 \uB123\uC73C\uBA74 \uC904\uBC14\uAFC8\uC5D0\uC11C \uC774\uBCA4\uD2B8\uAC00 \uB04A\uAE40). \uBB38\uC790\uC5F4\uC774 \uC544\uB2C8\uBA74 JSON.\n */\n export const sseChunk = (e: SseEvent): string => {\n const ev = typeof e === 'string' ? { data: e } : e;\n let out = '';\n if (ev.comment !== undefined) out += ev.comment.split(/\\r\\n|\\r|\\n/).map(l => `: ${l}\\n`).join('');\n if (ev.event !== undefined) out += `event: ${oneLine(ev.event)}\\n`;\n if (ev.id !== undefined) out += `id: ${oneLine(ev.id)}\\n`;\n if (ev.retry !== undefined) out += `retry: ${Math.max(0, Math.floor(ev.retry))}\\n`;\n if (ev.data !== undefined) {\n const text = typeof ev.data === 'string' ? ev.data : JSON.stringify(ev.data);\n out += text.split(/\\r\\n|\\r|\\n/).map(l => `data: ${l}\\n`).join('');\n }\n return out + '\\n';\n };\n\n /** \uC5F0\uACB0 \uC720\uC9C0\uC6A9 SSE \uC8FC\uC11D (\uBE0C\uB77C\uC6B0\uC800 EventSource \uB294 \uBB34\uC2DC) */\n export const ssePing = (): string => ': ping\\n\\n';\n\n export type Part =\n | Buffer\n | Uint8Array\n | string\n | { body: Buffer | Uint8Array | string; type?: string; name?: string; headers?: Record<string, string> };\n\n /** \uBC14\uC774\uD2B8 \uC55E\uBD80\uBD84\uC73C\uB85C \uD754\uD55C \uC774\uBBF8\uC9C0 \uD310\uBCC4 (mime-types \uB294 \uC774\uB984\uC73C\uB85C\uB9CC \uCC3E\uC74C) \u2014 \uC774\uB984 \uC5C6\uC774 Buffer\uB9CC \uC628 \uD504\uB808\uC784\uC6A9 */\n const sniff = (b: Buffer): string | undefined => {\n if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) return Mimes.ImageJpeg;\n if (b.length >= 8 && b.readUInt32BE(0) === 0x89504e47 && b.readUInt32BE(4) === 0x0d0a1a0a) return Mimes.ImagePng;\n if (b.length >= 6 && b.toString('ascii', 0, 4) === 'GIF8') return Mimes.ImageGif;\n if (b.length >= 12 && b.toString('ascii', 0, 4) === 'RIFF' && b.toString('ascii', 8, 12) === 'WEBP') return 'image/webp';\n return undefined;\n };\n\n /**\n * \uD30C\uD2B8 MIME: type > mime-types(name) > \uBC14\uC774\uD2B8 \uD310\uBCC4 > \uBB38\uC790\uC5F4\uC774\uBA74 text/plain;utf-8 > octet-stream\n */\n export const partType = (part: Part, fallback?: string): string => {\n const p = isPartObject(part) ? part : { body: part };\n if (p.type) return p.type;\n if (p.name) {\n const byName = mime.lookup(p.name);\n if (byName) return mime.contentType(byName) || byName;\n }\n if (typeof p.body === 'string') return fallback ?? Mimes.TextPlainUtf8;\n return sniff(Buffer.from(p.body.buffer, p.body.byteOffset, p.body.byteLength)) ?? fallback ?? Mimes.ApplicationOctetStream;\n };\n\n const isPartObject = (part: Part): part is Exclude<Part, Buffer | Uint8Array | string> =>\n typeof part === 'object' && !(part instanceof Uint8Array);\n\n const toBuffer = (body: Buffer | Uint8Array | string): Buffer =>\n typeof body === 'string' ? Buffer.from(body, 'utf8') : Buffer.isBuffer(body) ? body : Buffer.from(body.buffer, body.byteOffset, body.byteLength);\n\n /**\n * multipart \uD30C\uD2B8 \uD558\uB098: `--boundary\\r\\nContent-Type: \u2026\\r\\nContent-Length: <\uBC14\uC774\uD2B8 \uC218>\\r\\n[\uD5E4\uB354\u2026]\\r\\n\\r\\n<body>\\r\\n`\n * Content-Length \uB294 \uBB38\uC790\uC5F4\uB3C4 \uAE00\uC790 \uC218\uAC00 \uC544\uB2C8\uB77C UTF-8 \uBC14\uC774\uD2B8 \uC218.\n */\n export const multipartPart = (part: Part, boundary: string, fallbackType?: string): Buffer => {\n const p = isPartObject(part) ? part : { body: part };\n const body = toBuffer(p.body);\n let head = `--${boundary}\\r\\nContent-Type: ${partType(part, fallbackType)}\\r\\nContent-Length: ${body.length}\\r\\n`;\n for (const [k, v] of Object.entries(p.headers ?? {})) head += `${oneLine(k)}: ${oneLine(v)}\\r\\n`;\n return Buffer.concat([Buffer.from(head + '\\r\\n', 'latin1'), body, Buffer.from('\\r\\n')]);\n };\n\n /** multipart \uB05D \uD45C\uC2DC (multipart/mixed \uCC98\uB7FC \uB05D\uC774 \uC788\uB294 \uACBD\uC6B0) */\n export const multipartEnd = (boundary: string): Buffer => Buffer.from(`--${boundary}--\\r\\n`);\n\n /** NDJSON \uD55C \uC904: JSON + \\n (\uADF8\uB0E5 \uAC1D\uCCB4\uB97C yield \uD558\uBA74 \uC904\uBC14\uAFC8 \uC5C6\uC774 \uBD99\uC5B4\uC11C \uBC1B\uB294 \uCABD\uC774 \uBABB \uB098\uB214) */\n export const ndjsonLine = (value: unknown): string => json(value) + '\\n';\n\n /** JSON.stringify(undefined) \uB294 undefined \uB77C \uADF8\uB300\uB85C \uBD99\uC774\uBA74 \uAE68\uC9C4 JSON \u2014 \uBC30\uC5F4 \uC548\uCC98\uB7FC null \uB85C */\n const json = (value: unknown): string => JSON.stringify(value) ?? 'null';\n\n /** RFC 7464 application/json-seq \uB808\uCF54\uB4DC: RS(0x1E) + JSON + \\n */\n export const jsonSeqRecord = (value: unknown): string => '\\x1e' + json(value) + '\\n';\n\n /** CSV \uCE78 \uD558\uB098 (RFC 4180): \uC27C\uD45C\u00B7\uB530\uC634\uD45C\u00B7\uC904\uBC14\uAFC8\u00B7\uC55E\uB4A4 \uACF5\uBC31\uC774 \uC788\uC73C\uBA74 \"\u2026\" \uB85C \uAC10\uC2F8\uACE0 \" \uB294 \"\" */\n export const csvCell = (value: unknown): string => {\n if (value === null || value === undefined) return '';\n const s = typeof value === 'string' ? value : value instanceof Date ? value.toISOString() : typeof value === 'object' ? json(value) : String(value);\n return /[\",\\r\\n]|^\\s|\\s$/.test(s) ? `\"${s.replace(/\"/g, '\"\"')}\"` : s;\n };\n\n /** CSV \uD55C \uC904: \uCE78\uB4E4 + CRLF */\n export const csvRow = (cells: readonly unknown[]): string => cells.map(csvCell).join(',') + '\\r\\n';\n\n /** text/plain \uD55C \uC904: \uBB38\uC790\uC5F4\uC740 \uADF8\uB300\uB85C, \uB098\uBA38\uC9C0\uB294 JSON + \\n */\n export const textLine = (value: unknown): string => (typeof value === 'string' ? value : json(value)) + '\\n';\n\n /** RFC 2046: 1~70\uC790, \uD5C8\uC6A9 \uBB38\uC790\uB9CC, \uACF5\uBC31\uC73C\uB85C \uB05D\uB098\uC9C0 \uC54A\uAC8C */\n export const boundary = (value?: string): string => {\n const b = value ?? `boundary-${randomBytes(12).toString('hex')}`;\n if (!/^[0-9A-Za-z'()+_,\\-./:=? ]{0,69}[0-9A-Za-z'()+_,\\-./:=?]$/.test(b)) {\n throw new Error(`invalid multipart boundary: ${JSON.stringify(b)}`);\n }\n return b;\n };\n\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 pull: \uC6D0\uBCF8 generator \uAC10\uC2F8\uAE30 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n const toStream = <T>(gen: AsyncGenerator<T, void, undefined>, contentType: string, compress: boolean): Stream<T> =>\n Object.assign(gen, { contentType, compress });\n\n async function* encode<In, Out>(src: Source<In>, fn: (v: In) => Out): AsyncGenerator<Out, void, undefined> {\n // \uBC14\uAE65\uC774 return \uB418\uBA74(\uD074\uB77C\uC774\uC5B8\uD2B8 \uB04A\uAE40) for await \uAC00 \uC6D0\uBCF8\uC5D0\uB3C4 return \uC744 \uBD88\uB7EC \uC6D0\uBCF8\uC758 finally \uAC00 \uB3C8\uB2E4\n for await (const v of src as AsyncIterable<In>) yield fn(v);\n }\n\n /** \uC55E(start)\u00B7\uB0B4\uC6A9\u00B7\uB4A4(end). \uC911\uAC04\uC5D0 \uB04A\uAE30\uBA74(return) end \uB294 \uC548 \uB098\uAC10 */\n async function* framed<In, Out>(src: Source<In>, fn: (v: In) => Out, start?: Out, end?: Out): AsyncGenerator<Out, void, undefined> {\n if (start !== undefined) yield start;\n yield* encode(src, fn);\n if (end !== undefined) yield end;\n }\n\n /** JSON \uBC30\uC5F4 \uD56D\uBAA9: \uCCAB \uD56D\uBAA9 \uB9D0\uACE0\uB294 \uC55E\uC5D0 \uC27C\uD45C (\uC2A4\uD2B8\uB9BC\uB9C8\uB2E4 \uD558\uB098\uC529 \uB9CC\uB4E4\uC5B4 \uC500) */\n const jsonArrayItem = () => {\n let n = 0;\n return (v: unknown) => (n++ ? ',' : '') + json(v);\n };\n\n export type CsvRow = readonly unknown[] | Record<string, unknown>;\n export type CsvOption = {\n /** \uD5E4\uB354 \uC904 + \uAC1D\uCCB4 \uD589\uC744 \uC774 \uC21C\uC11C\uB85C \uCE78\uC5D0 \uB9DE\uCDA4 (\uC5C6\uC73C\uBA74 \uAC1D\uCCB4\uB294 Object.values \uC21C\uC11C, \uD5E4\uB354 \uC5C6\uC74C) */\n columns?: string[];\n /** UTF-8 BOM \u2014 Excel \uC774 \uD55C\uAE00 CSV \uB97C \uAE68\uC9C0\uC9C0 \uC54A\uAC8C \uC5F4\uB824\uBA74 \uD544\uC694 */\n bom?: boolean;\n };\n const csvEncoder = (opt: CsvOption) => (r: CsvRow) =>\n csvRow(Array.isArray(r) ? r : opt.columns ? opt.columns.map(c => (r as Record<string, unknown>)[c]) : Object.values(r));\n const csvStart = (opt: CsvOption): string | undefined =>\n opt.bom || opt.columns ? (opt.bom ? '\uFEFF' : '') + (opt.columns ? csvRow(opt.columns) : '') : undefined;\n const CsvType = `${Mimes.TextCsv}; charset=utf-8`;\n\n /**\n * text/event-stream. heartbeatMs \uB97C \uC8FC\uBA74 \uADF8\uB3D9\uC548 \uC774\uBCA4\uD2B8\uAC00 \uC5C6\uC744 \uB54C `: ping` \uC744 \uB07C\uC6CC \uC5F0\uACB0 \uC720\uC9C0\n * (\uD504\uB85D\uC2DC\u00B7\uBE0C\uB77C\uC6B0\uC800\uB294 \uC624\uB798 \uC870\uC6A9\uD55C \uC5F0\uACB0\uC744 \uB04A\uB294\uB2E4).\n */\n export function sse(src: Source<SseEvent>, opt: { heartbeatMs?: number } = {}): Stream<string> {\n const contentType = Mimes.TextEventStream;\n if (!opt.heartbeatMs) return toStream(encode(src, sseChunk), contentType, true);\n const ms = opt.heartbeatMs;\n async function* withPing(): AsyncGenerator<string, void, undefined> {\n const it = (Symbol.asyncIterator in (src as any)\n ? (src as AsyncIterable<SseEvent>)[Symbol.asyncIterator]()\n : (src as Iterable<SseEvent>)[Symbol.iterator]()) as AsyncIterator<SseEvent> | Iterator<SseEvent>;\n let pending: Promise<IteratorResult<SseEvent>> | undefined;\n try {\n while (true) {\n pending ??= Promise.resolve(it.next());\n let timer: ReturnType<typeof setTimeout> | undefined;\n const tick = new Promise<'ping'>(r => (timer = setTimeout(() => r('ping'), ms)));\n const r = await Promise.race([pending, tick]);\n clearTimeout(timer);\n if (r === 'ping') {\n yield ssePing(); // \uC6D0\uBCF8 next \uB294 \uADF8\uB300\uB85C \uAE30\uB2E4\uB9BC (pending \uC720\uC9C0)\n continue;\n }\n pending = undefined;\n if (r.done) return;\n yield sseChunk(r.value);\n }\n } finally {\n await it.return?.();\n }\n }\n return toStream(withPing(), contentType, true);\n }\n\n /** multipart/x-mixed-replace (MJPEG \uB4F1 \u2014 \uD30C\uD2B8\uAC00 \uC62C \uB54C\uB9C8\uB2E4 \uC55E \uAC83\uC744 \uAC08\uC544\uB07C\uC6C0). \uC774\uBBF8 \uC555\uCD95\uB41C \uB0B4\uC6A9\uC774\uB77C gzip \uC548 \uD568 */\n export function multipartReplace(src: Source<Part>, opt: { boundary?: string; type?: string } = {}): Stream<Buffer> {\n const b = boundary(opt.boundary);\n return toStream(encode(src, p => multipartPart(p, b, opt.type)), `multipart/x-mixed-replace; boundary=${b}`, false);\n }\n\n /** multipart/mixed (\uB05D\uC774 \uC788\uB294 \uC5EC\uB7EC \uD30C\uD2B8). \uC6D0\uBCF8\uC774 \uB05D\uB098\uBA74 `--boundary--` */\n export function multipartMixed(src: Source<Part>, opt: { boundary?: string; type?: string } = {}): Stream<Buffer> {\n const b = boundary(opt.boundary);\n return toStream(framed(src, p => multipartPart(p, b, opt.type), undefined, multipartEnd(b)), `multipart/mixed; boundary=${b}`, true);\n }\n\n /** application/x-ndjson (\uD55C \uC904\uC5D0 JSON \uD558\uB098) */\n export function ndjson(src: Source<unknown>): Stream<string> {\n return toStream(encode(src, ndjsonLine), Mimes.ApplicationXndjson, true);\n }\n\n /** application/json-seq (RFC 7464, \uB808\uCF54\uB4DC\uB9C8\uB2E4 RS \uB85C \uC2DC\uC791) */\n export function jsonSeq(src: Source<unknown>): Stream<string> {\n return toStream(encode(src, jsonSeqRecord), Mimes.ApplicationJsonSeq, true);\n }\n\n /**\n * application/json \uBC30\uC5F4\uC744 \uD56D\uBAA9\uB9C8\uB2E4 \uD758\uB824\uBCF4\uB0C4: `[` \uD56D\uBAA9 `,` \uD56D\uBAA9 \u2026 `]`.\n * \uBC1B\uB294 \uCABD\uC740 \uB2E4 \uBC1B\uC740 \uB4A4 \uD3C9\uBC94\uD55C JSON \uC73C\uB85C \uD30C\uC2F1 (\uB05D\uAE4C\uC9C0 \uBC1B\uC544\uC57C \uC720\uD6A8\uD55C JSON \u2014 \uC911\uAC04\uC5D0 \uB04A\uAE30\uBA74 \uAE68\uC9C4 JSON)\n */\n export function jsonArray(src: Source<unknown>): Stream<string> {\n return toStream(framed(src, jsonArrayItem(), '[', ']'), Mimes.ApplicationJson, true);\n }\n\n /** text/csv; charset=utf-8 \u2014 \uD589\uC740 \uBC30\uC5F4 \uB610\uB294 \uAC1D\uCCB4(columns \uC21C\uC11C). \uC904\uBC14\uAFC8 CRLF */\n export function csv(src: Source<CsvRow>, opt: CsvOption = {}): Stream<string> {\n return toStream(framed(src, csvEncoder(opt), csvStart(opt)), CsvType, true);\n }\n\n /** text/plain; charset=utf-8 \u2014 \uD55C \uC904\uC5D0 \uD558\uB098 (\uB85C\uADF8 tail \uB4F1) */\n export function text(src: Source<unknown>): Stream<string> {\n return toStream(encode(src, textLine), Mimes.TextPlainUtf8, true);\n }\n\n // \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 push: \uCC44\uB110 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /**\n * push \uD55C \uAC12\uC744 \uD050\uC5D0 \uB2F4\uC558\uB2E4\uAC00 yield \uD558\uB294 \uC2A4\uD2B8\uB9BC.\n * \uC9C1\uC811 iterator \uB97C \uB9CC\uB4DC\uB294 \uC774\uC720: \uAE30\uB2E4\uB9AC\uB294 \uC911(await)\uC5D0 \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uB04A\uACA8\uB3C4 return() \uC774 \uBC14\uB85C \uB05D\uB0B4\uACE0 onClose \uB97C \uBD80\uB974\uAC8C\n * (async generator \uB294 await \uC911\uC758 return \uC744 \uB2E4\uC74C yield \uAE4C\uC9C0 \uBBF8\uB904\uC11C, \uC870\uC6A9\uD55C \uCC44\uB110\uC774\uBA74 \uC815\uB9AC\uAC00 \uC548 \uB428).\n */\n export function channel<In, Out>(\n encodeFn: (v: In) => Out,\n contentType: string,\n compress: boolean,\n opt: ChannelOption & { start?: () => Out; end?: () => Out; heartbeat?: { ms: number; chunk: () => Out } } = {}\n ): Channel<In, Out> {\n const keep = opt.keep ?? 'queue';\n const max = Math.max(1, opt.max ?? 1000);\n const queue: In[] = [];\n const closers: (() => void)[] = [];\n let closed = false; // \uB354 \uC548 \uBC1B\uC74C (\uC313\uC778 \uAC74 \uBCF4\uB0C4)\n let finished = false; // \uC644\uC804\uD788 \uB05D\uB0A8\n let startSent = false;\n let endSent = false;\n let wake: (() => void) | undefined;\n\n const finish = () => {\n if (finished) return;\n finished = closed = true;\n queue.length = 0;\n opt.signal?.removeEventListener('abort', onAbort);\n wake?.();\n for (const fn of closers.splice(0)) {\n try { fn(); } catch { /* \uC815\uB9AC \uC2E4\uD328\uAC00 \uC751\uB2F5\uC744 \uAE68\uC9C0 \uC54A\uAC8C */ }\n }\n };\n const onAbort = () => finish();\n if (opt.signal?.aborted) closed = finished = true;\n else opt.signal?.addEventListener('abort', onAbort, { once: true });\n\n const next = async (): Promise<IteratorResult<Out, void>> => {\n while (!finished) {\n // \uC55E\uBD80\uBD84(JSON \uBC30\uC5F4 '[', CSV \uD5E4\uB354 \uB4F1)\uC740 \uCCAB next \uC5D0 \uBC14\uB85C \u2014 \uC544\uBB34\uAC83\uB3C4 push \uC548 \uD558\uACE0 close \uD574\uB3C4 \uB098\uAC10\n if (opt.start && !startSent) {\n startSent = true;\n return { value: opt.start(), done: false };\n }\n if (queue.length) return { value: encodeFn(queue.shift() as In), done: false };\n if (closed) {\n if (opt.end && !endSent) {\n endSent = true;\n return { value: opt.end(), done: false };\n }\n finish();\n break;\n }\n let timer: ReturnType<typeof setTimeout> | undefined;\n const ping = await new Promise<boolean>(resolve => {\n wake = () => resolve(false);\n if (opt.heartbeat) timer = setTimeout(() => resolve(true), opt.heartbeat.ms);\n });\n wake = undefined;\n clearTimeout(timer);\n if (ping && !finished && !queue.length && !closed) return { value: opt.heartbeat!.chunk(), done: false };\n }\n return { value: undefined, done: true };\n };\n\n const iterator: Channel<In, Out> = {\n contentType,\n compress,\n get closed() { return closed; },\n push(value: In) {\n if (closed) return false;\n if (keep === 'latest') queue.length = 0;\n else if (queue.length >= max) queue.shift();\n queue.push(value);\n wake?.();\n return true;\n },\n close() {\n closed = true;\n wake?.();\n },\n onClose(fn: () => void) {\n if (finished) fn();\n else closers.push(fn);\n },\n next,\n async return() {\n finish();\n return { value: undefined, done: true };\n },\n async throw(e?: unknown) {\n finish();\n throw e;\n },\n [Symbol.asyncIterator]() { return this; }\n } as unknown as Channel<In, Out>;\n // `await using` \uC815\uB9AC \uC9C0\uC6D0 (Symbol.asyncDispose \uAC00 \uC788\uB294 \uB7F0\uD0C0\uC784\uB9CC \u2014 AsyncGenerator \uD0C0\uC785\uC774 \uC694\uAD6C)\n const dispose = (Symbol as any).asyncDispose as symbol | undefined;\n if (dispose) (iterator as any)[dispose] = async () => finish();\n return iterator;\n }\n\n export namespace sse {\n /** push \uB85C SSE: out.push('hello') \u00B7 out.push({ event: 'tick', data: { n: 1 } }) */\n export const channel = (opt: ChannelOption & { heartbeatMs?: number } = {}): Channel<SseEvent, string> =>\n ContentTypeGenerator.channel(sseChunk, Mimes.TextEventStream, true, {\n ...opt,\n heartbeat: opt.heartbeatMs ? { ms: opt.heartbeatMs, chunk: ssePing } : undefined\n });\n }\n\n export namespace multipartReplace {\n /** push \uB85C MJPEG \uB4F1: out.push(jpegBuffer) \u2014 \uD504\uB808\uC784\uC740 \uBCF4\uD1B5 keep: 'latest' */\n export const channel = (opt: ChannelOption & { boundary?: string; type?: string } = {}): Channel<Part, Buffer> => {\n const b = boundary(opt.boundary);\n return ContentTypeGenerator.channel((p: Part) => multipartPart(p, b, opt.type), `multipart/x-mixed-replace; boundary=${b}`, false, opt);\n };\n }\n\n export namespace multipartMixed {\n export const channel = (opt: ChannelOption & { boundary?: string; type?: string } = {}): Channel<Part, Buffer> => {\n const b = boundary(opt.boundary);\n return ContentTypeGenerator.channel((p: Part) => multipartPart(p, b, opt.type), `multipart/mixed; boundary=${b}`, true, {\n ...opt,\n end: () => multipartEnd(b)\n });\n };\n }\n\n export namespace ndjson {\n export const channel = (opt: ChannelOption = {}): Channel<unknown, string> =>\n ContentTypeGenerator.channel(ndjsonLine, Mimes.ApplicationXndjson, true, opt);\n }\n\n export namespace jsonSeq {\n export const channel = (opt: ChannelOption = {}): Channel<unknown, string> =>\n ContentTypeGenerator.channel(jsonSeqRecord, Mimes.ApplicationJsonSeq, true, opt);\n }\n\n export namespace jsonArray {\n /** close \uD574\uC57C `]` \uAC00 \uB098\uAC00\uC11C \uC720\uD6A8\uD55C JSON \uC774 \uB428 */\n export const channel = (opt: ChannelOption = {}): Channel<unknown, string> =>\n ContentTypeGenerator.channel(jsonArrayItem(), Mimes.ApplicationJson, true, { ...opt, start: () => '[', end: () => ']' });\n }\n\n export namespace csv {\n export const channel = (opt: ChannelOption & CsvOption = {}): Channel<CsvRow, string> => {\n const start = csvStart(opt);\n return ContentTypeGenerator.channel(csvEncoder(opt), CsvType, true, { ...opt, start: start === undefined ? undefined : () => start });\n };\n }\n\n export namespace text {\n export const channel = (opt: ChannelOption = {}): Channel<unknown, string> =>\n ContentTypeGenerator.channel(textLine, Mimes.TextPlainUtf8, true, opt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AqB,CAAC,MAC5CP,sBAAqB,QAAQA,sBAAA,YAAY,MAAM,oBAAoB,MAAM,GAAG;AAAA,KAF/D,SAAAA,sBAAA,WAAAA,sBAAA;AAKV,IAAUQ,aAAV;AACE,IAAMA,SAAA,UAAU,CAAC,MAAqB,CAAC,MAC5CR,sBAAqB,QAAQA,sBAAA,eAAe,MAAM,oBAAoB,MAAM,GAAG;AAAA,KAFlE,UAAAA,sBAAA,YAAAA,sBAAA;AAKV,IAAUS,eAAV;AAEE,IAAMA,WAAA,UAAU,CAAC,MAAqB,CAAC,MAC5CT,sBAAqB,QAAQ,cAAc,GAAG,MAAM,iBAAiB,MAAM,EAAE,GAAG,KAAK,OAAO,MAAM,KAAK,KAAK,MAAM,IAAI,CAAC;AAAA,KAH1G,YAAAA,sBAAA,cAAAA,sBAAA;AAMV,IAAUU,SAAV;AACE,IAAMA,KAAA,UAAU,CAAC,MAAiC,CAAC,MAA+B;AACvF,YAAM,QAAQ,SAAS,GAAG;AAC1B,aAAOV,sBAAqB,QAAQ,WAAW,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,KAAK,OAAO,UAAU,SAAY,SAAY,MAAM,MAAM,CAAC;AAAA,IACtI;AAAA,KAJe,MAAAA,sBAAA,QAAAA,sBAAA;AAOV,IAAUC,UAAV;AACE,IAAMA,MAAA,UAAU,CAAC,MAAqB,CAAC,MAC5CD,sBAAqB,QAAQA,sBAAA,UAAU,MAAM,eAAe,MAAM,GAAG;AAAA,KAFxD,OAAAA,sBAAA,SAAAA,sBAAA;AAAA,GAtZF;",
|
|
6
|
+
"names": ["ContentTypeGenerator", "text", "boundary", "r", "sse", "multipartReplace", "multipartMixed", "ndjson", "jsonSeq", "jsonArray", "csv"]
|
|
7
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./decorators/index.js";
|
|
|
3
3
|
export * from "./endpoints/index.js";
|
|
4
4
|
export * from "./errors/index.js";
|
|
5
5
|
export * from "./filters/index.js";
|
|
6
|
+
export * from "./generators/ContentTypeGenerator.js";
|
|
6
7
|
export * from "./proxy/index.js";
|
|
7
8
|
export * from "./inject/index.js";
|
|
8
9
|
export * from "./lifecycle/index.js";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './codes';\nexport * from './decorators';\nexport * from './endpoints';\nexport * from './errors';\nexport * from './filters';\nexport * from './proxy';\nexport * from './inject';\nexport * from './lifecycle';\nexport * from './models';\nexport * from './option';\nexport * from './resolvers';\nexport * from './session';\nexport * from './SimpleBootHttpServer';\nexport default {}"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,IAAO,cAAQ,CAAC;",
|
|
4
|
+
"sourcesContent": ["export * from './codes';\nexport * from './decorators';\nexport * from './endpoints';\nexport * from './errors';\nexport * from './filters';\nexport * from './generators/ContentTypeGenerator';\nexport * from './proxy';\nexport * from './inject';\nexport * from './lifecycle';\nexport * from './models';\nexport * from './option';\nexport * from './resolvers';\nexport * from './session';\nexport * from './SimpleBootHttpServer';\nexport default {}"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,IAAO,cAAQ,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|