@contember/engine-http 2.1.0-alpha.16 → 2.1.0-alpha.18
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/development/index.cjs +0 -2
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +0 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +1 -2
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +1 -2
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/application/application.cjs +10 -3
- package/dist/development/src/application/application.cjs.map +1 -1
- package/dist/development/src/application/application.js +10 -3
- package/dist/development/src/application/application.js.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs +13 -7
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js +13 -7
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/utils/remoteAddress.cjs +58 -0
- package/dist/development/src/utils/remoteAddress.cjs.map +1 -0
- package/dist/development/src/utils/remoteAddress.js +58 -0
- package/dist/development/src/utils/remoteAddress.js.map +1 -0
- package/dist/production/index.cjs +0 -2
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +0 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +1 -2
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +1 -2
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/application/application.cjs +10 -3
- package/dist/production/src/application/application.cjs.map +1 -1
- package/dist/production/src/application/application.js +10 -3
- package/dist/production/src/application/application.js.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs +13 -7
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js +13 -7
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/utils/remoteAddress.cjs +58 -0
- package/dist/production/src/utils/remoteAddress.cjs.map +1 -0
- package/dist/production/src/utils/remoteAddress.js +58 -0
- package/dist/production/src/utils/remoteAddress.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +1 -3
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/application/application.d.ts +1 -0
- package/dist/types/application/application.d.ts.map +1 -1
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts +0 -6
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/tenant/index.d.ts +0 -1
- package/dist/types/tenant/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/remoteAddress.d.ts +3 -0
- package/dist/types/utils/remoteAddress.d.ts.map +1 -0
- package/package.json +16 -15
- package/src/MasterContainer.ts +3 -5
- package/src/application/application.ts +11 -4
- package/src/tenant/TenantApiMiddlewareFactory.ts +15 -10
- package/src/tenant/index.ts +0 -1
- package/src/utils/remoteAddress.ts +70 -0
- package/dist/development/src/tenant/TenantGraphQLContextFactory.cjs +0 -19
- package/dist/development/src/tenant/TenantGraphQLContextFactory.cjs.map +0 -1
- package/dist/development/src/tenant/TenantGraphQLContextFactory.js +0 -19
- package/dist/development/src/tenant/TenantGraphQLContextFactory.js.map +0 -1
- package/dist/production/src/tenant/TenantGraphQLContextFactory.cjs +0 -19
- package/dist/production/src/tenant/TenantGraphQLContextFactory.cjs.map +0 -1
- package/dist/production/src/tenant/TenantGraphQLContextFactory.js +0 -19
- package/dist/production/src/tenant/TenantGraphQLContextFactory.js.map +0 -1
- package/dist/types/tenant/TenantGraphQLContextFactory.d.ts +0 -12
- package/dist/types/tenant/TenantGraphQLContextFactory.d.ts.map +0 -1
- package/src/tenant/TenantGraphQLContextFactory.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sources":["../../../../../packages/engine-http/src/application/application.ts"],"sourcesContent":["import { Key, pathToRegexp } from 'path-to-regexp'\nimport { KoaContext, KoaMiddleware } from './types'\nimport { AuthResult, HttpErrorResponse, HttpResponse } from '../common'\nimport Koa from 'koa'\nimport * as http from 'node:http'\nimport { IncomingMessage, Server, ServerResponse } from 'node:http'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport { FingerCrossedLoggerHandler, Logger } from '@contember/logger'\nimport koaCompress from 'koa-compress'\nimport bodyParser from 'koa-bodyparser'\nimport { ServerConfig } from '../config/config'\nimport corsMiddleware from '@koa/cors'\nimport stream, { Duplex, Readable } from 'node:stream'\nimport { ProjectGroupResolver } from '../projectGroup/ProjectGroupResolver'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\nimport { URL } from 'node:url'\nimport { cpuUsage, memoryUsage } from 'node:process'\nimport { performance } from 'node:perf_hooks'\n\ntype Route<C> = { match: RequestMatcher; controller: C; module: string }\nexport class Application {\n\n\tprivate middlewares: KoaMiddleware<any>[] = []\n\n\tprivate routes: Route<HttpController>[] = []\n\tprivate internalRoutes: Route<InternalHttpController>[] = []\n\tprivate websocketRoutes: Route<WebSocketController>[] = []\n\n\tprivate suppressAccessLog: boolean | RegExp\n\n\tconstructor(\n\t\tprivate readonly projectGroupResolver: ProjectGroupResolver,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly debugMode: boolean,\n\t\tprivate readonly version: string | undefined,\n\t\tprivate readonly logger: Logger,\n\t) {\n\t\tconst suppressAccessLogRaw = serverConfig.http?.suppressAccessLog\n\t\tthis.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false\n\t}\n\n\taddMiddleware(middleware: KoaMiddleware<any>) {\n\t\tthis.middlewares.push(middleware)\n\t}\n\n\tpublic addRoute(module: string, mask: string, controller: HttpController): void {\n\t\tthis.routes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addInternalRoute(module: string, mask: string, controller: InternalHttpController): void {\n\t\tthis.internalRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addWebsocketRoute(module: string, mask: string, controller: WebSocketController): void {\n\t\tthis.websocketRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tasync listen(): Promise<RunningApplication> {\n\t\tconst koa = new Koa()\n\t\tconst wss = new WebSocketServer({ noServer: true })\n\t\tfor (const middleware of this.middlewares) {\n\t\t\tkoa.use(middleware)\n\t\t}\n\t\tkoa.use(koaCompress({\n\t\t\tbr: false,\n\t\t}))\n\t\tkoa.use(bodyParser({\n\t\t\tjsonLimit: this.serverConfig.http?.requestBodySize || '1mb',\n\t\t}))\n\t\tkoa.use(corsMiddleware())\n\t\tconst versionMatch = this.version?.match(/^(0\\.\\d+|\\d+)/)\n\t\tconst versionSimplified = versionMatch?.[1] ?? 'unknown'\n\t\tkoa.use(async ctx => {\n\t\t\tctx.response.set('X-Powered-By', `Contember ${versionSimplified}` + (this.debugMode ? '-dev' : ''))\n\t\t\tawait this.handleHttpRequest(ctx)\n\t\t})\n\n\t\tconst server = http.createServer(koa.callback())\n\t\tconst abortController = new AbortController()\n\n\t\tconst wsRequests: (Promise<void>)[] = []\n\t\tserver.on('upgrade', (req, socket, head) => {\n\t\t\t wsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head))\n\t\t})\n\t\tawait new Promise<void>(resolve => {\n\t\t\tserver.listen(this.serverConfig.port, () => resolve())\n\t\t})\n\n\t\treturn {\n\t\t\tserver,\n\t\t\tclose: async () => {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait Promise.all(wsRequests)\n\t\t\t\tawait new Promise(resolve => server.close(resolve))\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate async handleWebsocketRequest(\n\t\twss: WebSocketServer,\n\t\tabortSignal: AbortSignal,\n\t\treq: IncomingMessage,\n\t\tsocket: stream.Duplex,\n\t\thead: Buffer,\n\t): Promise<void> {\n\t\tlet webSocketContext: WebSocketContext | null = null\n\t\tlet requestLogger = this.logger\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\t\ttry {\n\t\t\tconst url = new URL(req.url ?? '/', `http://${req.headers.host}`)\n\t\t\tconst matchedRequest = this.matchRequest(this.websocketRoutes, url)\n\t\t\tif (!matchedRequest) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Route not found')\n\t\t\t}\n\t\t\trequestLogger = this.createRequestLogger(req, undefined, matchedRequest.module)\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: req })\n\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst ws = await new Promise<WebSocket>(resolve => wss.handleUpgrade(req, socket, head, (ws, request) => {\n\t\t\t\tresolve(ws)\n\t\t\t}))\n\t\t\tconst wsEstablished = performance.now()\n\t\t\twebSocketContext = {\n\t\t\t\tws,\n\t\t\t\tabortSignal,\n\t\t\t\tlogger: requestLogger,\n\t\t\t\ttimer,\n\t\t\t\turl,\n\t\t\t\trequest: req,\n\t\t\t\tauthResult,\n\t\t\t\tparams: matchedRequest.params,\n\t\t\t\tprojectGroup: groupContainer,\n\t\t\t}\n\t\t\tawait matchedRequest.controller(webSocketContext)\n\t\t\trequestLogger.debug('Websocket connection established')\n\t\t\tws.on('error', e => {\n\t\t\t\trequestLogger.error(e, {\n\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t})\n\t\t\t})\n\n\t\t\treturn new Promise<void>(resolve => {\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\trequestLogger.debug('Websocket connection closed', {\n\t\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t\t})\n\t\t\t\t\tresolve()\n\t\t\t\t})\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendRawHttpResponse(socket, e)\n\t\t\t} else {\n\t\t\t\tthis.sendRawHttpResponse(socket, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t\trequestLogger.debug('Websocket connection failed')\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq,\n\t\t\t\trequestDebugMode: false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate async handleHttpRequest(ctx: KoaContext<{ module?: string; projectGroup?: string; project?: string }>) {\n\t\tconst matchedRequest = this.matchRequest(this.routes, ctx.request.URL)\n\t\tif (!matchedRequest) {\n\t\t\tconst internalMatchedRequest = this.matchRequest(this.internalRoutes, ctx.request.URL)\n\t\t\tif (internalMatchedRequest) {\n\t\t\t\treturn await this.handleInternalRequest(internalMatchedRequest, ctx)\n\t\t\t}\n\t\t}\n\t\tlet httpContext: HttpContext | null = null\n\t\tlet requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module)\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\n\t\ttry {\n\t\t\tif (!matchedRequest) {\n\t\t\t\treturn this.sendHttpResponse(ctx, new HttpErrorResponse(404, 'Route not found'))\n\t\t\t}\n\t\t\trequestLogger.debug('Request processing started', {\n\t\t\t\tbody: ctx.request.body,\n\t\t\t\tquery: ctx.request.query,\n\t\t\t})\n\n\t\t\t// todo: solve without koa context (required by prom metrics)\n\t\t\tctx.state.module = matchedRequest.module\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: ctx.req })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\t\t\tctx.state.projectGroup = groupContainer.slug\n\t\t\tctx.state.project = matchedRequest.params.projectSlug\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\n\t\t\tconst response = await requestLogger.scope(async logger => {\n\t\t\t\thttpContext = {\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\ttimer,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\trequestDebugMode: false,\n\t\t\t\t\tauthResult,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t\tprojectGroup: groupContainer,\n\t\t\t\t}\n\t\t\t\treturn await matchedRequest.controller(httpContext)\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq: ctx.req,\n\t\t\t\tresponse: ctx.res,\n\t\t\t\tbody: ctx.response.body,\n\t\t\t\trequestDebugMode: (httpContext as HttpContext | null)?.requestDebugMode ?? false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t\trequestLogger.debug('Request processing finished')\n\t\t}\n\t}\n\n\n\tprivate async handleInternalRequest(matchedRequest: MatchedRequest<InternalHttpController>, ctx: KoaContext<{ module?: string }>) {\n\t\ttry {\n\t\t\tconst response = await this.logger.scope(async logger => {\n\t\t\t\treturn await matchedRequest.controller({\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t})\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\tthis.logger.error(e)\n\t\t\t}\n\t\t}\n\t}\n\n\n\tprivate sendHttpResponse(ctx: KoaContext<{}>, response: HttpResponse) {\n\t\tif (response.contentType) {\n\t\t\tctx.set('Content-type', response.contentType)\n\t\t}\n\t\tctx.status = response.code\n\t\tif (response.body !== undefined) {\n\t\t\tctx.body = response.body\n\t\t}\n\t}\n\n\tprivate sendRawHttpResponse(socket: Duplex, response: HttpResponse) {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Connection': 'close',\n\t\t\t'Content-Type': response.contentType ?? 'text/plain',\n\t\t\t'Content-Length': String(response.body?.length ?? 0),\n\t\t}\n\n\t\tsocket.once('finish', socket.destroy)\n\n\t\tsocket.end(\n\t\t\t`HTTP/1.1 ${response.code} ${http.STATUS_CODES[response.code]}\\r\\n` +\n\t\t\tObject.keys(headers)\n\t\t\t\t.map(h => `${h}: ${headers[h]}`)\n\t\t\t\t.join('\\r\\n') +\n\t\t\t'\\r\\n\\r\\n' +\n\t\t\t(response.body ?? ''),\n\t\t)\n\t}\n\n\tprivate createRequestLogger(request: IncomingMessage, body: any, module?: string): Logger {\n\t\treturn this.logger.child({\n\t\t\tmethod: request.method,\n\t\t\turi: request.url,\n\t\t\trequestId: Math.random().toString().substring(2),\n\t\t\tmodule,\n\t\t\t[LoggerRequestBody]: body,\n\t\t}, {\n\t\t\thandler: FingerCrossedLoggerHandler.factory(),\n\t\t})\n\t}\n\n\tprivate createTimer() {\n\t\tconst times: EventTime[] = []\n\t\tconst globalStart = performance.now()\n\t\tconst cpuUsageStart = cpuUsage()\n\t\tconst memoryUsageStart = memoryUsage()\n\t\tconst timer: Timer = (name: string, cb) => {\n\t\t\tconst start = performance.now()\n\t\t\tconst time: EventTime = { label: name, start: Math.round(start - globalStart) }\n\t\t\ttimes.push(time)\n\t\t\tconst res = cb()\n\n\t\t\tif (res instanceof Promise) {\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait res\n\t\t\t\t\t} catch {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\ttime.duration = Math.round(performance.now() - start)\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t}\n\t\t\treturn res\n\t\t}\n\n\t\tconst send = (ctx: { req: IncomingMessage; response?: ServerResponse; body?: unknown; requestDebugMode: boolean; logger: Logger }) => {\n\t\t\tif (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {\n\t\t\t\tctx.response.setHeader('server-timing', times.map(it => `${it.label};desc=\"${it.label} T+${it.start}\";dur=${it.duration ?? -1}`).join(', '))\n\t\t\t}\n\n\t\t\tconst emit = () => {\n\t\t\t\tconst total = performance.now() - globalStart\n\t\t\t\tconst timeLabel = total > 500 ? 'TIME_SLOW' : 'TIME_OK'\n\t\t\t\tconst shouldSuppress = this.suppressAccessLog === true || !ctx.req.url || (this.suppressAccessLog !== false && this.suppressAccessLog.test(ctx.req.url))\n\n\t\t\t\tconst cpuUsageEnd = cpuUsage()\n\t\t\t\tconst memoryUsageEnd = memoryUsage()\n\n\t\t\t\tconst cpuUsageDiffMs = (cpuUsageEnd.user - cpuUsageStart.user) / 1000\n\t\t\t\tconst memoryUsageDiff = memoryUsageEnd.heapUsed - memoryUsageStart.heapUsed\n\t\t\t\tconst level = shouldSuppress ? 'debug' : 'info'\n\t\t\t\tctx.logger.log(level, !ctx.response ? 'Connection established' : ctx.response.statusCode < 400 ? `Request successful` : 'Request failed', {\n\t\t\t\t\tstatus: ctx.response?.statusCode,\n\t\t\t\t\ttimeLabel: timeLabel,\n\t\t\t\t\ttotalTimeMs: Math.round(total),\n\t\t\t\t\tevents: times,\n\t\t\t\t\tcpuUsageDiffMs,\n\t\t\t\t\tmemoryUsageDiff,\n\t\t\t\t\tresponseBodySize: ctx.body && typeof ctx.body === 'string' ? ctx.body.length : undefined,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (ctx.body instanceof Readable) {\n\t\t\t\tconst body = ctx.body\n\t\t\t\tconst streamTimer = timer('Stream', () => {\n\t\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\t\tbody.addListener('close', () => {\n\t\t\t\t\t\t\tresolve(null)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tstreamTimer.then(emit).catch(emit)\n\n\t\t\t} else {\n\t\t\t\temit()\n\t\t\t}\n\n\t\t}\n\t\treturn { timer, send }\n\t}\n\n\tprivate matchRequest<C>(routes: Route<C>[], url: URL): MatchedRequest<C> | null {\n\t\tfor (const route of routes) {\n\t\t\tconst params = route.match({ url })\n\t\t\tif (params !== null) {\n\t\t\t\treturn { params, controller: route.controller, module: route.module }\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\n\ntype EventTime = { label: string; start: number; duration?: number }\n\nexport type Timer = <T>(event: string, cb: () => T) => T\n\nexport type MatchedRequest<C> = { params: Params; controller: C; module: string }\n\nexport type BaseRequestContext = {\n\tlogger: Logger\n\trequest: IncomingMessage\n\turl: URL\n\tparams: Params\n}\n\nexport type ApplicationContext =\n\t& BaseRequestContext\n\t& {\n\t\tprojectGroup: ProjectGroupContainer\n\t\tauthResult: AuthResult | null\n\t\ttimer: Timer\n\t}\n\nexport type BaseHttpRequestContext = {\n\tkoa: KoaContext<{}>\n\tbody: unknown\n\tresponse: ServerResponse\n}\n\nexport type HttpContext =\n\t& ApplicationContext\n\t& BaseHttpRequestContext\n\t& {\n\t\trequestDebugMode: boolean\n\t}\n\nexport type InternalHttpContext =\n\t& BaseRequestContext\n\t& BaseHttpRequestContext\n\nexport type WebSocketContext =\n\t& ApplicationContext\n\t& {\n\t\tws: WebSocket\n\t\tabortSignal: AbortSignal\n\t}\n\nexport type HttpControllerResponse = Promise<HttpErrorResponse | undefined | void> | HttpErrorResponse | undefined | void\nexport type HttpController = (context: HttpContext) => HttpControllerResponse\nexport type InternalHttpController = (context: InternalHttpContext) => HttpControllerResponse\n\nexport type WebSocketController = (context: WebSocketContext) => void\n\ntype Params = { [param: string]: string }\n\ntype RequestMatcher = (args: { url: URL }) => Params | null\nconst createRequestMatcher = (\n\tmask: string,\n): RequestMatcher => {\n\tconst keys: Key[] = []\n\tconst regexp: RegExp = pathToRegexp(mask, keys)\n\n\tconst match = function (url: string): Params | null {\n\t\tconst match = regexp.exec(url)\n\t\tif (match) {\n\t\t\treturn match.slice(1).reduce((acc, value, i) => ({ ...acc, [keys[i].name]: value }), {})\n\t\t}\n\t\treturn null\n\t}\n\n\treturn request => {\n\t\treturn match(request.url.pathname)\n\t}\n}\n\nexport const LoggerRequestBody = Symbol('RequestBody')\n\nexport interface RunningApplication {\n\tclose(): Promise<void>\n\treadonly server: Server\n}\n"],"names":["ws","match"],"mappings":";;;;;;;;;;;;;;;;AAoBO,MAAM,YAAY;AAAA,EAUxB,YACkB,sBACA,cACA,WACA,SACA,QAChB;AALgB,SAAA,uBAAA;AACA,SAAA,eAAA;AACA,SAAA,YAAA;AACA,SAAA,UAAA;AACA,SAAA,SAAA;AAblB,kBAAA,MAAQ,eAAoC,EAAC;AAE7C,kBAAA,MAAQ,UAAkC,EAAC;AAC3C,kBAAA,MAAQ,kBAAkD,EAAC;AAC3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"],"sourcesContent":["import { Key, pathToRegexp } from 'path-to-regexp'\nimport { KoaContext, KoaMiddleware } from './types'\nimport { AuthResult, HttpErrorResponse, HttpResponse } from '../common'\nimport Koa from 'koa'\nimport * as http from 'node:http'\nimport { IncomingMessage, Server, ServerResponse } from 'node:http'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport { FingerCrossedLoggerHandler, Logger } from '@contember/logger'\nimport koaCompress from 'koa-compress'\nimport bodyParser from 'koa-bodyparser'\nimport { ServerConfig } from '../config/config'\nimport corsMiddleware from '@koa/cors'\nimport stream, { Duplex, Readable } from 'node:stream'\nimport { ProjectGroupResolver } from '../projectGroup/ProjectGroupResolver'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\nimport { URL } from 'node:url'\nimport { cpuUsage, memoryUsage } from 'node:process'\nimport { performance } from 'node:perf_hooks'\nimport { getClientIP } from '../utils/remoteAddress'\n\ntype Route<C> = { match: RequestMatcher; controller: C; module: string }\nexport class Application {\n\n\tprivate middlewares: KoaMiddleware<any>[] = []\n\n\tprivate routes: Route<HttpController>[] = []\n\tprivate internalRoutes: Route<InternalHttpController>[] = []\n\tprivate websocketRoutes: Route<WebSocketController>[] = []\n\n\tprivate suppressAccessLog: boolean | RegExp\n\n\tconstructor(\n\t\tprivate readonly projectGroupResolver: ProjectGroupResolver,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly debugMode: boolean,\n\t\tprivate readonly version: string | undefined,\n\t\tprivate readonly logger: Logger,\n\t) {\n\t\tconst suppressAccessLogRaw = serverConfig.http?.suppressAccessLog\n\t\tthis.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false\n\t}\n\n\taddMiddleware(middleware: KoaMiddleware<any>) {\n\t\tthis.middlewares.push(middleware)\n\t}\n\n\tpublic addRoute(module: string, mask: string, controller: HttpController): void {\n\t\tthis.routes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addInternalRoute(module: string, mask: string, controller: InternalHttpController): void {\n\t\tthis.internalRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addWebsocketRoute(module: string, mask: string, controller: WebSocketController): void {\n\t\tthis.websocketRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tasync listen(): Promise<RunningApplication> {\n\t\tconst koa = new Koa()\n\t\tconst wss = new WebSocketServer({ noServer: true })\n\t\tfor (const middleware of this.middlewares) {\n\t\t\tkoa.use(middleware)\n\t\t}\n\t\tkoa.use(koaCompress({\n\t\t\tbr: false,\n\t\t}))\n\t\tkoa.use(bodyParser({\n\t\t\tjsonLimit: this.serverConfig.http?.requestBodySize || '1mb',\n\t\t}))\n\t\tkoa.use(corsMiddleware())\n\t\tconst versionMatch = this.version?.match(/^(0\\.\\d+|\\d+)/)\n\t\tconst versionSimplified = versionMatch?.[1] ?? 'unknown'\n\t\tkoa.use(async ctx => {\n\t\t\tctx.response.set('X-Powered-By', `Contember ${versionSimplified}` + (this.debugMode ? '-dev' : ''))\n\t\t\tawait this.handleHttpRequest(ctx)\n\t\t})\n\n\t\tconst server = http.createServer(koa.callback())\n\t\tconst abortController = new AbortController()\n\n\t\tconst wsRequests: (Promise<void>)[] = []\n\t\tserver.on('upgrade', (req, socket, head) => {\n\t\t\t wsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head))\n\t\t})\n\t\tawait new Promise<void>(resolve => {\n\t\t\tserver.listen(this.serverConfig.port, () => resolve())\n\t\t})\n\n\t\treturn {\n\t\t\tserver,\n\t\t\tclose: async () => {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait Promise.all(wsRequests)\n\t\t\t\tawait new Promise(resolve => server.close(resolve))\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate async handleWebsocketRequest(\n\t\twss: WebSocketServer,\n\t\tabortSignal: AbortSignal,\n\t\treq: IncomingMessage,\n\t\tsocket: stream.Duplex,\n\t\thead: Buffer,\n\t): Promise<void> {\n\t\tlet webSocketContext: WebSocketContext | null = null\n\t\tlet requestLogger = this.logger\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\t\tconst clientIp = getClientIP(req)\n\t\ttry {\n\t\t\tconst url = new URL(req.url ?? '/', `http://${req.headers.host}`)\n\t\t\tconst matchedRequest = this.matchRequest(this.websocketRoutes, url)\n\t\t\tif (!matchedRequest) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Route not found')\n\t\t\t}\n\t\t\trequestLogger = this.createRequestLogger(req, undefined, matchedRequest.module, clientIp)\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: req })\n\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst ws = await new Promise<WebSocket>(resolve => wss.handleUpgrade(req, socket, head, (ws, request) => {\n\t\t\t\tresolve(ws)\n\t\t\t}))\n\t\t\tconst wsEstablished = performance.now()\n\t\t\twebSocketContext = {\n\t\t\t\tws,\n\t\t\t\tabortSignal,\n\t\t\t\tlogger: requestLogger,\n\t\t\t\ttimer,\n\t\t\t\turl,\n\t\t\t\trequest: req,\n\t\t\t\tclientIp,\n\t\t\t\tauthResult,\n\t\t\t\tparams: matchedRequest.params,\n\t\t\t\tprojectGroup: groupContainer,\n\t\t\t}\n\t\t\tawait matchedRequest.controller(webSocketContext)\n\t\t\trequestLogger.debug('Websocket connection established')\n\t\t\tws.on('error', e => {\n\t\t\t\trequestLogger.error(e, {\n\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t})\n\t\t\t})\n\n\t\t\treturn new Promise<void>(resolve => {\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\trequestLogger.debug('Websocket connection closed', {\n\t\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t\t})\n\t\t\t\t\tresolve()\n\t\t\t\t})\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendRawHttpResponse(socket, e)\n\t\t\t} else {\n\t\t\t\tthis.sendRawHttpResponse(socket, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t\trequestLogger.debug('Websocket connection failed')\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq,\n\t\t\t\trequestDebugMode: false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate async handleHttpRequest(ctx: KoaContext<{ module?: string; projectGroup?: string; project?: string }>) {\n\t\tconst matchedRequest = this.matchRequest(this.routes, ctx.request.URL)\n\t\tif (!matchedRequest) {\n\t\t\tconst internalMatchedRequest = this.matchRequest(this.internalRoutes, ctx.request.URL)\n\t\t\tif (internalMatchedRequest) {\n\t\t\t\treturn await this.handleInternalRequest(internalMatchedRequest, ctx)\n\t\t\t}\n\t\t}\n\t\tlet httpContext: HttpContext | null = null\n\t\tconst clientIp = getClientIP(ctx.req)\n\t\tlet requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp)\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\n\t\ttry {\n\t\t\tif (!matchedRequest) {\n\t\t\t\treturn this.sendHttpResponse(ctx, new HttpErrorResponse(404, 'Route not found'))\n\t\t\t}\n\t\t\trequestLogger.debug('Request processing started', {\n\t\t\t\tbody: ctx.request.body,\n\t\t\t\tquery: ctx.request.query,\n\t\t\t})\n\n\t\t\t// todo: solve without koa context (required by prom metrics)\n\t\t\tctx.state.module = matchedRequest.module\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: ctx.req })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\t\t\tctx.state.projectGroup = groupContainer.slug\n\t\t\tctx.state.project = matchedRequest.params.projectSlug\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst response = await requestLogger.scope(async logger => {\n\t\t\t\thttpContext = {\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tclientIp,\n\t\t\t\t\tlogger,\n\t\t\t\t\ttimer,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\trequestDebugMode: false,\n\t\t\t\t\tauthResult,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t\tprojectGroup: groupContainer,\n\t\t\t\t}\n\t\t\t\treturn await matchedRequest.controller(httpContext)\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq: ctx.req,\n\t\t\t\tresponse: ctx.res,\n\t\t\t\tbody: ctx.response.body,\n\t\t\t\trequestDebugMode: (httpContext as HttpContext | null)?.requestDebugMode ?? false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t\trequestLogger.debug('Request processing finished')\n\t\t}\n\t}\n\n\n\tprivate async handleInternalRequest(matchedRequest: MatchedRequest<InternalHttpController>, ctx: KoaContext<{ module?: string }>) {\n\t\ttry {\n\t\t\tconst response = await this.logger.scope(async logger => {\n\t\t\t\treturn await matchedRequest.controller({\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tclientIp: getClientIP(ctx.req),\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t})\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\tthis.logger.error(e)\n\t\t\t}\n\t\t}\n\t}\n\n\n\tprivate sendHttpResponse(ctx: KoaContext<{}>, response: HttpResponse) {\n\t\tif (response.contentType) {\n\t\t\tctx.set('Content-type', response.contentType)\n\t\t}\n\t\tctx.status = response.code\n\t\tif (response.body !== undefined) {\n\t\t\tctx.body = response.body\n\t\t}\n\t}\n\n\tprivate sendRawHttpResponse(socket: Duplex, response: HttpResponse) {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Connection': 'close',\n\t\t\t'Content-Type': response.contentType ?? 'text/plain',\n\t\t\t'Content-Length': String(response.body?.length ?? 0),\n\t\t}\n\n\t\tsocket.once('finish', socket.destroy)\n\n\t\tsocket.end(\n\t\t\t`HTTP/1.1 ${response.code} ${http.STATUS_CODES[response.code]}\\r\\n` +\n\t\t\tObject.keys(headers)\n\t\t\t\t.map(h => `${h}: ${headers[h]}`)\n\t\t\t\t.join('\\r\\n') +\n\t\t\t'\\r\\n\\r\\n' +\n\t\t\t(response.body ?? ''),\n\t\t)\n\t}\n\n\tprivate createRequestLogger(request: IncomingMessage, body: any, module?: string, remoteAddress?: string): Logger {\n\t\treturn this.logger.child({\n\t\t\tmethod: request.method,\n\t\t\turi: request.url,\n\t\t\trequestId: Math.random().toString().substring(2),\n\t\t\tmodule,\n\t\t\tremoteAddress,\n\t\t\t[LoggerRequestBody]: body,\n\t\t}, {\n\t\t\thandler: FingerCrossedLoggerHandler.factory(),\n\t\t})\n\t}\n\n\tprivate createTimer() {\n\t\tconst times: EventTime[] = []\n\t\tconst globalStart = performance.now()\n\t\tconst cpuUsageStart = cpuUsage()\n\t\tconst memoryUsageStart = memoryUsage()\n\t\tconst timer: Timer = (name: string, cb) => {\n\t\t\tconst start = performance.now()\n\t\t\tconst time: EventTime = { label: name, start: Math.round(start - globalStart) }\n\t\t\ttimes.push(time)\n\t\t\tconst res = cb()\n\n\t\t\tif (res instanceof Promise) {\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait res\n\t\t\t\t\t} catch {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\ttime.duration = Math.round(performance.now() - start)\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t}\n\t\t\treturn res\n\t\t}\n\n\t\tconst send = (ctx: { req: IncomingMessage; response?: ServerResponse; body?: unknown; requestDebugMode: boolean; logger: Logger }) => {\n\t\t\tif (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {\n\t\t\t\tctx.response.setHeader('server-timing', times.map(it => `${it.label};desc=\"${it.label} T+${it.start}\";dur=${it.duration ?? -1}`).join(', '))\n\t\t\t}\n\n\t\t\tconst emit = () => {\n\t\t\t\tconst total = performance.now() - globalStart\n\t\t\t\tconst timeLabel = total > 500 ? 'TIME_SLOW' : 'TIME_OK'\n\t\t\t\tconst shouldSuppress = this.suppressAccessLog === true || !ctx.req.url || (this.suppressAccessLog !== false && this.suppressAccessLog.test(ctx.req.url))\n\n\t\t\t\tconst cpuUsageEnd = cpuUsage()\n\t\t\t\tconst memoryUsageEnd = memoryUsage()\n\n\t\t\t\tconst cpuUsageDiffMs = (cpuUsageEnd.user - cpuUsageStart.user) / 1000\n\t\t\t\tconst memoryUsageDiff = memoryUsageEnd.heapUsed - memoryUsageStart.heapUsed\n\t\t\t\tconst level = shouldSuppress ? 'debug' : 'info'\n\t\t\t\tctx.logger.log(level, !ctx.response ? 'Connection established' : ctx.response.statusCode < 400 ? `Request successful` : 'Request failed', {\n\t\t\t\t\tstatus: ctx.response?.statusCode,\n\t\t\t\t\ttimeLabel: timeLabel,\n\t\t\t\t\ttotalTimeMs: Math.round(total),\n\t\t\t\t\tevents: times,\n\t\t\t\t\tcpuUsageDiffMs,\n\t\t\t\t\tmemoryUsageDiff,\n\t\t\t\t\tresponseBodySize: ctx.body && typeof ctx.body === 'string' ? ctx.body.length : undefined,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (ctx.body instanceof Readable) {\n\t\t\t\tconst body = ctx.body\n\t\t\t\tconst streamTimer = timer('Stream', () => {\n\t\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\t\tbody.addListener('close', () => {\n\t\t\t\t\t\t\tresolve(null)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tstreamTimer.then(emit).catch(emit)\n\n\t\t\t} else {\n\t\t\t\temit()\n\t\t\t}\n\n\t\t}\n\t\treturn { timer, send }\n\t}\n\n\tprivate matchRequest<C>(routes: Route<C>[], url: URL): MatchedRequest<C> | null {\n\t\tfor (const route of routes) {\n\t\t\tconst params = route.match({ url })\n\t\t\tif (params !== null) {\n\t\t\t\treturn { params, controller: route.controller, module: route.module }\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\n\ntype EventTime = { label: string; start: number; duration?: number }\n\nexport type Timer = <T>(event: string, cb: () => T) => T\n\nexport type MatchedRequest<C> = { params: Params; controller: C; module: string }\n\nexport type BaseRequestContext = {\n\tlogger: Logger\n\trequest: IncomingMessage\n\turl: URL\n\tparams: Params\n\tclientIp: string\n}\n\nexport type ApplicationContext =\n\t& BaseRequestContext\n\t& {\n\t\tprojectGroup: ProjectGroupContainer\n\t\tauthResult: AuthResult | null\n\t\ttimer: Timer\n\t}\n\nexport type BaseHttpRequestContext = {\n\tkoa: KoaContext<{}>\n\tbody: unknown\n\tresponse: ServerResponse\n}\n\nexport type HttpContext =\n\t& ApplicationContext\n\t& BaseHttpRequestContext\n\t& {\n\t\trequestDebugMode: boolean\n\t}\n\nexport type InternalHttpContext =\n\t& BaseRequestContext\n\t& BaseHttpRequestContext\n\nexport type WebSocketContext =\n\t& ApplicationContext\n\t& {\n\t\tws: WebSocket\n\t\tabortSignal: AbortSignal\n\t}\n\nexport type HttpControllerResponse = Promise<HttpErrorResponse | undefined | void> | HttpErrorResponse | undefined | void\nexport type HttpController = (context: HttpContext) => HttpControllerResponse\nexport type InternalHttpController = (context: InternalHttpContext) => HttpControllerResponse\n\nexport type WebSocketController = (context: WebSocketContext) => void\n\ntype Params = { [param: string]: string }\n\ntype RequestMatcher = (args: { url: URL }) => Params | null\nconst createRequestMatcher = (\n\tmask: string,\n): RequestMatcher => {\n\tconst keys: Key[] = []\n\tconst regexp: RegExp = pathToRegexp(mask, keys)\n\n\tconst match = function (url: string): Params | null {\n\t\tconst match = regexp.exec(url)\n\t\tif (match) {\n\t\t\treturn match.slice(1).reduce((acc, value, i) => ({ ...acc, [keys[i].name]: value }), {})\n\t\t}\n\t\treturn null\n\t}\n\n\treturn request => {\n\t\treturn match(request.url.pathname)\n\t}\n}\n\nexport const LoggerRequestBody = Symbol('RequestBody')\n\nexport interface RunningApplication {\n\tclose(): Promise<void>\n\treadonly server: Server\n}\n"],"names":["ws","match"],"mappings":";;;;;;;;;;;;;;;;;AAqBO,MAAM,YAAY;AAAA,EAUxB,YACkB,sBACA,cACA,WACA,SACA,QAChB;AALgB,SAAA,uBAAA;AACA,SAAA,eAAA;AACA,SAAA,YAAA;AACA,SAAA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,OAAO,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAA,IAAU,EAAE;AAAA,IAAA;AAEjF,WAAA;AAAA,EACR;AAEA,SAAO,CAAW,YAAA;AACV,WAAA,MAAM,QAAQ,IAAI,QAAQ;AAAA,EAClC;AACD;AAEa,MAAA,oBAAoB,OAAO,aAAa;"}
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const HttpResponse = require("../common/HttpResponse.cjs");
|
|
4
4
|
class TenantApiMiddlewareFactory {
|
|
5
|
-
constructor(debug, projectGroupResolver, tenantGraphQLContextFactory) {
|
|
6
|
-
this.debug = debug;
|
|
7
|
-
this.projectGroupResolver = projectGroupResolver;
|
|
8
|
-
this.tenantGraphQLContextFactory = tenantGraphQLContextFactory;
|
|
9
|
-
}
|
|
10
5
|
create() {
|
|
11
6
|
return async (ctx) => {
|
|
12
|
-
const { timer, projectGroup, authResult, logger, koa } = ctx;
|
|
7
|
+
const { timer, projectGroup, authResult, logger, koa, clientIp } = ctx;
|
|
13
8
|
if (!authResult) {
|
|
14
9
|
return new HttpResponse.HttpErrorResponse(401, "Authentication required");
|
|
15
10
|
}
|
|
@@ -23,7 +18,18 @@ class TenantApiMiddlewareFactory {
|
|
|
23
18
|
koa.state.graphql = {
|
|
24
19
|
operationName: operation
|
|
25
20
|
};
|
|
26
|
-
|
|
21
|
+
const resolverContextFactory = tenantContainer.resolverContextFactory;
|
|
22
|
+
const db = tenantContainer.databaseContext;
|
|
23
|
+
const context = resolverContextFactory.create(
|
|
24
|
+
authResult,
|
|
25
|
+
{ ip: clientIp, userAgent: koa.request.headers["user-agent"] },
|
|
26
|
+
db,
|
|
27
|
+
logger2
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
...context,
|
|
31
|
+
identityId: authResult.identityId
|
|
32
|
+
};
|
|
27
33
|
}
|
|
28
34
|
}));
|
|
29
35
|
logger2.debug("Tenant query finished");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantApiMiddlewareFactory.cjs","sources":["../../../../../packages/engine-http/src/tenant/TenantApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { HttpErrorResponse } from '../common'\nimport {
|
|
1
|
+
{"version":3,"file":"TenantApiMiddlewareFactory.cjs","sources":["../../../../../packages/engine-http/src/tenant/TenantApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { HttpErrorResponse } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport class TenantApiMiddlewareFactory {\n\n\n\tcreate(): HttpController {\n\t\treturn async ctx => {\n\t\t\tconst { timer, projectGroup, authResult, logger, koa, clientIp } = ctx\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('Tenant query processing started')\n\t\t\t\tawait timer('GraphQL', () => projectGroup.tenantGraphQLHandler({\n\t\t\t\t\trequest: koa.request,\n\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst resolverContextFactory = tenantContainer.resolverContextFactory\n\t\t\t\t\t\tconst db = tenantContainer.databaseContext\n\t\t\t\t\t\tconst context = resolverContextFactory.create(\n\t\t\t\t\t\t\tauthResult,\n\t\t\t\t\t\t\t{ ip: clientIp, userAgent: koa.request.headers['user-agent'] },\n\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tlogger.debug('Tenant query finished')\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse","logger"],"mappings":";;;AAIO,MAAM,2BAA2B;AAAA,EAGvC,SAAyB;AACxB,WAAO,OAAM,QAAO;AACnB,YAAM,EAAE,OAAO,cAAc,YAAY,QAAQ,KAAK,aAAa;AACnE,UAAI,CAAC,YAAY;AACT,eAAA,IAAIA,aAAAA,kBAAkB,KAAK,yBAAyB;AAAA,MAAA;AAE5D,YAAM,kBAAkB,aAAa;AAC/B,YAAA,OAAO,MAAM,OAAMC,YAAU;AAClCA,gBAAO,MAAM,iCAAiC;AAC9C,cAAM,MAAM,WAAW,MAAM,aAAa,qBAAqB;AAAA,UAC9D,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAChC,gBAAI,MAA0B,UAAU;AAAA,cACxC,eAAe;AAAA,YAChB;AACA,kBAAM,yBAAyB,gBAAgB;AAC/C,kBAAM,KAAK,gBAAgB;AAC3B,kBAAM,UAAU,uBAAuB;AAAA,cACtC;AAAA,cACA,EAAE,IAAI,UAAU,WAAW,IAAI,QAAQ,QAAQ,YAAY,EAAE;AAAA,cAC7D;AAAA,cACAA;AAAAA,YACD;AAEO,mBAAA;AAAA,cACN,GAAG;AAAA,cACH,YAAY,WAAW;AAAA,YACxB;AAAA,UAAA;AAAA,QAED,CACA,CAAC;AACFA,gBAAO,MAAM,uBAAuB;AAAA,MAAA,CACpC;AAAA,IACF;AAAA,EAAA;AAEF;;"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { HttpErrorResponse } from "../common/HttpResponse.js";
|
|
2
2
|
class TenantApiMiddlewareFactory {
|
|
3
|
-
constructor(debug, projectGroupResolver, tenantGraphQLContextFactory) {
|
|
4
|
-
this.debug = debug;
|
|
5
|
-
this.projectGroupResolver = projectGroupResolver;
|
|
6
|
-
this.tenantGraphQLContextFactory = tenantGraphQLContextFactory;
|
|
7
|
-
}
|
|
8
3
|
create() {
|
|
9
4
|
return async (ctx) => {
|
|
10
|
-
const { timer, projectGroup, authResult, logger, koa } = ctx;
|
|
5
|
+
const { timer, projectGroup, authResult, logger, koa, clientIp } = ctx;
|
|
11
6
|
if (!authResult) {
|
|
12
7
|
return new HttpErrorResponse(401, "Authentication required");
|
|
13
8
|
}
|
|
@@ -21,7 +16,18 @@ class TenantApiMiddlewareFactory {
|
|
|
21
16
|
koa.state.graphql = {
|
|
22
17
|
operationName: operation
|
|
23
18
|
};
|
|
24
|
-
|
|
19
|
+
const resolverContextFactory = tenantContainer.resolverContextFactory;
|
|
20
|
+
const db = tenantContainer.databaseContext;
|
|
21
|
+
const context = resolverContextFactory.create(
|
|
22
|
+
authResult,
|
|
23
|
+
{ ip: clientIp, userAgent: koa.request.headers["user-agent"] },
|
|
24
|
+
db,
|
|
25
|
+
logger2
|
|
26
|
+
);
|
|
27
|
+
return {
|
|
28
|
+
...context,
|
|
29
|
+
identityId: authResult.identityId
|
|
30
|
+
};
|
|
25
31
|
}
|
|
26
32
|
}));
|
|
27
33
|
logger2.debug("Tenant query finished");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantApiMiddlewareFactory.js","sources":["../../../../../packages/engine-http/src/tenant/TenantApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { HttpErrorResponse } from '../common'\nimport {
|
|
1
|
+
{"version":3,"file":"TenantApiMiddlewareFactory.js","sources":["../../../../../packages/engine-http/src/tenant/TenantApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { HttpErrorResponse } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport class TenantApiMiddlewareFactory {\n\n\n\tcreate(): HttpController {\n\t\treturn async ctx => {\n\t\t\tconst { timer, projectGroup, authResult, logger, koa, clientIp } = ctx\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('Tenant query processing started')\n\t\t\t\tawait timer('GraphQL', () => projectGroup.tenantGraphQLHandler({\n\t\t\t\t\trequest: koa.request,\n\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst resolverContextFactory = tenantContainer.resolverContextFactory\n\t\t\t\t\t\tconst db = tenantContainer.databaseContext\n\t\t\t\t\t\tconst context = resolverContextFactory.create(\n\t\t\t\t\t\t\tauthResult,\n\t\t\t\t\t\t\t{ ip: clientIp, userAgent: koa.request.headers['user-agent'] },\n\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...context,\n\t\t\t\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tlogger.debug('Tenant query finished')\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["logger"],"mappings":";AAIO,MAAM,2BAA2B;AAAA,EAGvC,SAAyB;AACxB,WAAO,OAAM,QAAO;AACnB,YAAM,EAAE,OAAO,cAAc,YAAY,QAAQ,KAAK,aAAa;AACnE,UAAI,CAAC,YAAY;AACT,eAAA,IAAI,kBAAkB,KAAK,yBAAyB;AAAA,MAAA;AAE5D,YAAM,kBAAkB,aAAa;AAC/B,YAAA,OAAO,MAAM,OAAMA,YAAU;AAClCA,gBAAO,MAAM,iCAAiC;AAC9C,cAAM,MAAM,WAAW,MAAM,aAAa,qBAAqB;AAAA,UAC9D,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAChC,gBAAI,MAA0B,UAAU;AAAA,cACxC,eAAe;AAAA,YAChB;AACA,kBAAM,yBAAyB,gBAAgB;AAC/C,kBAAM,KAAK,gBAAgB;AAC3B,kBAAM,UAAU,uBAAuB;AAAA,cACtC;AAAA,cACA,EAAE,IAAI,UAAU,WAAW,IAAI,QAAQ,QAAQ,YAAY,EAAE;AAAA,cAC7D;AAAA,cACAA;AAAAA,YACD;AAEO,mBAAA;AAAA,cACN,GAAG;AAAA,cACH,YAAY,WAAW;AAAA,YACxB;AAAA,UAAA;AAAA,QAED,CACA,CAAC;AACFA,gBAAO,MAAM,uBAAuB;AAAA,MAAA,CACpC;AAAA,IACF;AAAA,EAAA;AAEF;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const ipaddr = require("ipaddr.js");
|
|
4
|
+
function isPrivate(ip) {
|
|
5
|
+
let addr;
|
|
6
|
+
try {
|
|
7
|
+
addr = ipaddr.parse(ip);
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const r = addr.range();
|
|
12
|
+
if (r === "ipv4Mapped") {
|
|
13
|
+
return addr.toIPv4Address().range() === "private";
|
|
14
|
+
}
|
|
15
|
+
return r === "private" || r === "uniqueLocal" || r === "linkLocal";
|
|
16
|
+
}
|
|
17
|
+
function isInCIDR(ip, cidrs) {
|
|
18
|
+
if (!cidrs || cidrs.length === 0) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
let addr;
|
|
22
|
+
try {
|
|
23
|
+
addr = ipaddr.parse(ip);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return cidrs.some((c) => {
|
|
28
|
+
try {
|
|
29
|
+
return addr.match(ipaddr.parseCIDR(c));
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function getClientIP(req, trustedProxies) {
|
|
36
|
+
const remote = req.socket.remoteAddress || "";
|
|
37
|
+
if (!isPrivate(remote) && !isInCIDR(remote, [])) {
|
|
38
|
+
return remote;
|
|
39
|
+
}
|
|
40
|
+
const xffHeader = req.headers["x-forwarded-for"];
|
|
41
|
+
let xffList = [];
|
|
42
|
+
if (Array.isArray(xffHeader)) {
|
|
43
|
+
xffHeader.forEach(
|
|
44
|
+
(h) => xffList.push(...h.split(",").map((ip) => ip.trim()).filter(Boolean))
|
|
45
|
+
);
|
|
46
|
+
} else if (typeof xffHeader === "string") {
|
|
47
|
+
xffList = xffHeader.split(",").map((ip) => ip.trim()).filter(Boolean);
|
|
48
|
+
}
|
|
49
|
+
for (let i = xffList.length - 1; i >= 0; i--) {
|
|
50
|
+
const ip = xffList[i];
|
|
51
|
+
if (!isPrivate(ip) && !isInCIDR(ip, [])) {
|
|
52
|
+
return ip;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return remote;
|
|
56
|
+
}
|
|
57
|
+
exports.getClientIP = getClientIP;
|
|
58
|
+
//# sourceMappingURL=remoteAddress.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteAddress.cjs","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\treturn (addr as ipaddr.IPv6).toIPv4Address().range() === 'private'\n\t}\n\n\treturn r === 'private' // IPv4 RFC1918\n\t\t|| r === 'uniqueLocal' // IPv6 fc00::/7\n\t\t|| r === 'linkLocal' // IPv6 fe80::/10\n}\n\n\nfunction isInCIDR(ip: string, cidrs: string[]): boolean {\n\tif (!cidrs || cidrs.length === 0) {\n\t\treturn false\n\t}\n\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\treturn cidrs.some(c => {\n\t\ttry {\n\t\t\treturn addr.match(ipaddr.parseCIDR(c))\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n}\n\nexport function getClientIP(req: IncomingMessage, trustedProxies?: string[]): string {\n\tconst remote = req.socket.remoteAddress || ''\n\n\tif (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {\n\t\treturn remote\n\t}\n\n\tconst xffHeader = req.headers['x-forwarded-for']\n\tlet xffList: string[] = []\n\n\tif (Array.isArray(xffHeader)) {\n\t\txffHeader.forEach(h =>\n\t\t\txffList.push(...h.split(',').map(ip => ip.trim()).filter(Boolean)),\n\t\t)\n\t} else if (typeof xffHeader === 'string') {\n\t\txffList = xffHeader.split(',').map(ip => ip.trim()).filter(Boolean)\n\t}\n\n\tfor (let i = xffList.length - 1; i >= 0; i--) {\n\t\tconst ip = xffList[i]\n\t\tif (!isPrivate(ip) && !isInCIDR(ip, trustedProxies || [])) {\n\t\t\treturn ip\n\t\t}\n\t}\n\n\treturn remote\n}\n"],"names":[],"mappings":";;;AAIA,SAAS,UAAU,IAAqB;AACnC,MAAA;AACA,MAAA;AACI,WAAA,OAAO,MAAM,EAAE;AAAA,EAAA,QACf;AACA,WAAA;AAAA,EAAA;AAGF,QAAA,IAAI,KAAK,MAAM;AACrB,MAAI,MAAM,cAAc;AACvB,WAAQ,KAAqB,gBAAgB,MAAY,MAAA;AAAA,EAAA;AAG1D,SAAO,MAAM,aACT,MAAM,iBACN,MAAM;AACX;AAGA,SAAS,SAAS,IAAY,OAA0B;AACvD,MAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAC1B,WAAA;AAAA,EAAA;AAGJ,MAAA;AACA,MAAA;AACI,WAAA,OAAO,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v4Mapped") {
|
|
11
|
+
return addr.toIPv4Address().range() === "private";
|
|
12
|
+
}
|
|
13
|
+
return r === "private" || r === "uniqueLocal" || r === "linkLocal";
|
|
14
|
+
}
|
|
15
|
+
function isInCIDR(ip, cidrs) {
|
|
16
|
+
if (!cidrs || cidrs.length === 0) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
let addr;
|
|
20
|
+
try {
|
|
21
|
+
addr = ipaddr.parse(ip);
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return cidrs.some((c) => {
|
|
26
|
+
try {
|
|
27
|
+
return addr.match(ipaddr.parseCIDR(c));
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getClientIP(req, trustedProxies) {
|
|
34
|
+
const remote = req.socket.remoteAddress || "";
|
|
35
|
+
if (!isPrivate(remote) && !isInCIDR(remote, [])) {
|
|
36
|
+
return remote;
|
|
37
|
+
}
|
|
38
|
+
const xffHeader = req.headers["x-forwarded-for"];
|
|
39
|
+
let xffList = [];
|
|
40
|
+
if (Array.isArray(xffHeader)) {
|
|
41
|
+
xffHeader.forEach(
|
|
42
|
+
(h) => xffList.push(...h.split(",").map((ip) => ip.trim()).filter(Boolean))
|
|
43
|
+
);
|
|
44
|
+
} else if (typeof xffHeader === "string") {
|
|
45
|
+
xffList = xffHeader.split(",").map((ip) => ip.trim()).filter(Boolean);
|
|
46
|
+
}
|
|
47
|
+
for (let i = xffList.length - 1; i >= 0; i--) {
|
|
48
|
+
const ip = xffList[i];
|
|
49
|
+
if (!isPrivate(ip) && !isInCIDR(ip, [])) {
|
|
50
|
+
return ip;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return remote;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
getClientIP
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=remoteAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteAddress.js","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\treturn (addr as ipaddr.IPv6).toIPv4Address().range() === 'private'\n\t}\n\n\treturn r === 'private' // IPv4 RFC1918\n\t\t|| r === 'uniqueLocal' // IPv6 fc00::/7\n\t\t|| r === 'linkLocal' // IPv6 fe80::/10\n}\n\n\nfunction isInCIDR(ip: string, cidrs: string[]): boolean {\n\tif (!cidrs || cidrs.length === 0) {\n\t\treturn false\n\t}\n\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\treturn cidrs.some(c => {\n\t\ttry {\n\t\t\treturn addr.match(ipaddr.parseCIDR(c))\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n}\n\nexport function getClientIP(req: IncomingMessage, trustedProxies?: string[]): string {\n\tconst remote = req.socket.remoteAddress || ''\n\n\tif (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {\n\t\treturn remote\n\t}\n\n\tconst xffHeader = req.headers['x-forwarded-for']\n\tlet xffList: string[] = []\n\n\tif (Array.isArray(xffHeader)) {\n\t\txffHeader.forEach(h =>\n\t\t\txffList.push(...h.split(',').map(ip => ip.trim()).filter(Boolean)),\n\t\t)\n\t} else if (typeof xffHeader === 'string') {\n\t\txffList = xffHeader.split(',').map(ip => ip.trim()).filter(Boolean)\n\t}\n\n\tfor (let i = xffList.length - 1; i >= 0; i--) {\n\t\tconst ip = xffList[i]\n\t\tif (!isPrivate(ip) && !isInC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AC,EAAE,OAAO,OAAO;AAAA,EAAA;AAGnE,WAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AACvC,UAAA,KAAK,QAAQ,CAAC;AAChB,QAAA,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,IAAsB,CAAA,CAAE,GAAG;AACnD,aAAA;AAAA,IAAA;AAAA,EACR;AAGM,SAAA;AACR;"}
|
|
@@ -22,7 +22,6 @@ const SystemGraphQLContextFactory = require("./src/system/SystemGraphQLContextFa
|
|
|
22
22
|
const SystemGraphQLHandlerFactory = require("./src/system/SystemGraphQLHandlerFactory.cjs");
|
|
23
23
|
const TenantApiMiddlewareFactory = require("./src/tenant/TenantApiMiddlewareFactory.cjs");
|
|
24
24
|
const TenantGraphQLHandlerFactory = require("./src/tenant/TenantGraphQLHandlerFactory.cjs");
|
|
25
|
-
const TenantGraphQLContextFactory = require("./src/tenant/TenantGraphQLContextFactory.cjs");
|
|
26
25
|
const ImportApiMiddlewareFactory = require("./src/transfer/ImportApiMiddlewareFactory.cjs");
|
|
27
26
|
const ExportApiControllerFactory = require("./src/transfer/ExportApiControllerFactory.cjs");
|
|
28
27
|
const ImportExecutor = require("./src/transfer/ImportExecutor.cjs");
|
|
@@ -69,7 +68,6 @@ exports.SystemGraphQLContextFactory = SystemGraphQLContextFactory.SystemGraphQLC
|
|
|
69
68
|
exports.SystemGraphQLHandlerFactory = SystemGraphQLHandlerFactory.SystemGraphQLHandlerFactory;
|
|
70
69
|
exports.TenantApiMiddlewareFactory = TenantApiMiddlewareFactory.TenantApiMiddlewareFactory;
|
|
71
70
|
exports.TenantGraphQLHandlerFactory = TenantGraphQLHandlerFactory.TenantGraphQLHandlerFactory;
|
|
72
|
-
exports.TenantGraphQLContextFactory = TenantGraphQLContextFactory.TenantGraphQLContextFactory;
|
|
73
71
|
exports.ImportApiMiddlewareFactory = ImportApiMiddlewareFactory.ImportApiMiddlewareFactory;
|
|
74
72
|
exports.ExportApiControllerFactory = ExportApiControllerFactory.ExportApiControllerFactory;
|
|
75
73
|
exports.ImportError = ImportExecutor.ImportError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -20,7 +20,6 @@ import { SystemGraphQLContextFactory } from "./src/system/SystemGraphQLContextFa
|
|
|
20
20
|
import { SystemGraphQLHandlerFactory } from "./src/system/SystemGraphQLHandlerFactory.js";
|
|
21
21
|
import { TenantApiMiddlewareFactory } from "./src/tenant/TenantApiMiddlewareFactory.js";
|
|
22
22
|
import { TenantGraphQLHandlerFactory } from "./src/tenant/TenantGraphQLHandlerFactory.js";
|
|
23
|
-
import { TenantGraphQLContextFactory } from "./src/tenant/TenantGraphQLContextFactory.js";
|
|
24
23
|
import { ImportApiMiddlewareFactory } from "./src/transfer/ImportApiMiddlewareFactory.js";
|
|
25
24
|
import { ExportApiControllerFactory } from "./src/transfer/ExportApiControllerFactory.js";
|
|
26
25
|
import { ImportError, ImportExecutor } from "./src/transfer/ImportExecutor.js";
|
|
@@ -79,7 +78,6 @@ export {
|
|
|
79
78
|
SystemGraphQLHandlerFactory,
|
|
80
79
|
SystemSchemaTransferMappingFactory,
|
|
81
80
|
TenantApiMiddlewareFactory,
|
|
82
|
-
TenantGraphQLContextFactory,
|
|
83
81
|
TenantGraphQLHandlerFactory,
|
|
84
82
|
createContainer,
|
|
85
83
|
createDbQueriesListener,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAI,uBAAA,EAAyB,OAAO,IAAI;AAChD;"}
|
|
@@ -13,7 +13,6 @@ const engineContentApi = require("@contember/engine-content-api");
|
|
|
13
13
|
const providers = require("./providers.cjs");
|
|
14
14
|
const TenantApiMiddlewareFactory = require("./tenant/TenantApiMiddlewareFactory.cjs");
|
|
15
15
|
const TenantGraphQLHandlerFactory = require("./tenant/TenantGraphQLHandlerFactory.cjs");
|
|
16
|
-
const TenantGraphQLContextFactory = require("./tenant/TenantGraphQLContextFactory.cjs");
|
|
17
16
|
const SystemApiMiddlewareFactory = require("./system/SystemApiMiddlewareFactory.cjs");
|
|
18
17
|
const SystemGraphQLContextFactory = require("./system/SystemGraphQLContextFactory.cjs");
|
|
19
18
|
const SystemGraphQLHandlerFactory = require("./system/SystemGraphQLHandlerFactory.cjs");
|
|
@@ -84,7 +83,7 @@ class MasterContainerFactory {
|
|
|
84
83
|
serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper.CryptoWrapper(encryptionKey) : void 0,
|
|
85
84
|
projectGroupContainerResolver
|
|
86
85
|
);
|
|
87
|
-
}).addService("notModifiedChecker", () => new NotModifiedChecker.NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers: providers2, executionContainerFactory }) => new ContentGraphQLContextFactory.ContentGraphQLContextFactory(providers2, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory.ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver.ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory.ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("
|
|
86
|
+
}).addService("notModifiedChecker", () => new NotModifiedChecker.NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers: providers2, executionContainerFactory }) => new ContentGraphQLContextFactory.ContentGraphQLContextFactory(providers2, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory.ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver.ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory.ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory.TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory.SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory.SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory.ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory.SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor.ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor.ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory.ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory.ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
|
|
88
87
|
const app = new application.Application(
|
|
89
88
|
projectGroupResolver,
|
|
90
89
|
serverConfig2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MasterContainer.cjs","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { Builder } from '@contember/dic'\nimport { ServerConfig } from './config/config'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\n\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { Logger } from '@contember/logger'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { createProviders, Providers } from './providers'\nimport { TenantApiMiddlewareFactory, TenantGraphQLContextFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport {\n\tContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ProjectContextResolver } from './project-common'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { Application } from './application'\nimport { ApplicationWorkerManager } from './workers'\nimport { HttpResponse } from './common'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport Koa from 'koa'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { createSecretKey } from 'node:crypto'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentGraphqlContextFactory', ({ providers, executionContainerFactory }) =>\n\t\t\t\tnew ContentGraphQLContextFactory(providers, executionContainerFactory))\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantGraphQLContextFactory', () =>\n\t\t\t\tnew TenantGraphQLContextFactory())\n\t\t\t.addService('tenantApiMiddlewareFactory', ({ debugMode, projectGroupResolver, tenantGraphQLContextFactory }) =>\n\t\t\t\tnew TenantApiMiddlewareFactory(debugMode, projectGroupResolver, tenantGraphQLContextFactory))\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["Builder","createProviders","providers","TenantContainerFactory","ModificationHandlerFactory","ExecutionContainerFactory","GraphQlSchemaBuilderFactory","ContentQueryExecutorImpl","SystemContainerFactory","PermissionFactory","DatabaseMetadataResolver","serverConfig","ContentApiSpecificCache","plugins","GraphQlSchemaFactory","ProjectContainerFactoryFactory","TenantGraphQLHandlerFactory","debugMode","SystemGraphQLHandlerFactory","projectConfigResolver","logger","ProjectGroupContainerFactory","tenantConfigResolver","ProjectGroupContainerResolver","processType","version","PrometheusRegistryFactory","ProjectGroupContainerMetricsHook","createSecretKey","ProjectGroupResolver","CryptoWrapper","NotModifiedChecker","ContentGraphQLContextFactory","ContentQueryHandlerFactory","ProjectContextResolver","ContentApiControllerFactory","TenantGraphQLContextFactory","TenantApiMiddlewareFactory","SystemGraphQLContextFactory","SystemApiMiddlewareFactory","ContentSchemaTransferMappingFactory","SystemSchemaTransferMappingFactory","ImportExecutor","ExportExecutor","ImportApiMiddlewareFactory","ExportApiControllerFactory","Application","createColllectHttpMetricsMiddleware","homepageController","HttpResponse","Initializer","ApplicationWorkerManager","createShowMetricsMiddleware"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM,QAAQ,KAAK,QACjB,IAAI,CAAM,OAAA,GAAG,yBAA0B,CAAA,EACvC,OAAO,CAAC,OAAkC,OAAO,MAAS;AACrD,WAAA,MAAM,OAAO,CAAC,KAAK,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AA,SAAS,QAAQ,KAAKC,0BAAAA,kBAAkB;AAExC,SAAA,iBAAiB,YAAY,WAAW,MAAM;AACzC,eAAA,IAAIC,aAAAA,aAAa,KAAK,IAAI;AAAA,MAAA,CACjC;AAAA,IAAA,CACD,EACA,WAAW,eAAe,CAAC,EAAE,sBAC7B,MAAA,IAAIC,YAAY,YAAA,qBAAqB,CAAC,EACtC,WAAW,sBAAsB,MACjC,IAAIC,yBAAAA,0BAA0B,EAC9B,aAAa,6BAA6B,CAAC,IAAI,EAAE,SAAAtC,eAAc;AAC/D,iBAAW,UAAUA,UAAS;AAC7B,YAAI,OAAO,2BAA2B;AACrC,aAAG,MAAM,KAAK,OAAO,0BAAA,CAA2B;AAAA,QAAA;AAAA,MACjD;AAAA,IAED,CAAA,EACA,WAAW,iBAAiB,CAAC,EAAE,mBAAmB;AAC5C,YAAA,MAAM,IAAI,IAAI;AAChB,UAAA,IAAIuC,kDAA4B,YAAY,CAAC;AAE1C,aAAA;AAAA,IAAA,CACP;AAAA,EAAA;AAAA,EAIH,OAAO,MAA4C;AAClD,UAAM,YAAY,KAAK,cAAc,IAAI,EAAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;;"}
|
|
1
|
+
{"version":3,"file":"MasterContainer.cjs","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { Builder } from '@contember/dic'\nimport { ServerConfig } from './config/config'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\n\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { Logger } from '@contember/logger'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { createProviders, Providers } from './providers'\nimport { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport {\n\tContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ProjectContextResolver } from './project-common'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { Application } from './application'\nimport { ApplicationWorkerManager } from './workers'\nimport { HttpResponse } from './common'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport Koa from 'koa'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { createSecretKey } from 'node:crypto'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentGraphqlContextFactory', ({ providers, executionContainerFactory }) =>\n\t\t\t\tnew ContentGraphQLContextFactory(providers, executionContainerFactory))\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantApiMiddlewareFactory', () =>\n\t\t\t\tnew TenantApiMiddlewareFactory())\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["Builder","createProviders","providers","TenantContainerFactory","ModificationHandlerFactory","ExecutionContainerFactory","GraphQlSchemaBuilderFactory","ContentQueryExecutorImpl","SystemContainerFactory","PermissionFactory","DatabaseMetadataResolver","serverConfig","ContentApiSpecificCache","plugins","GraphQlSchemaFactory","ProjectContainerFactoryFactory","TenantGraphQLHandlerFactory","debugMode","SystemGraphQLHandlerFactory","projectConfigResolver","logger","ProjectGroupContainerFactory","tenantConfigResolver","ProjectGroupContainerResolver","processType","version","PrometheusRegistryFactory","ProjectGroupContainerMetricsHook","createSecretKey","ProjectGroupResolver","CryptoWrapper","NotModifiedChecker","ContentGraphQLContextFactory","ContentQueryHandlerFactory","ProjectContextResolver","ContentApiControllerFactory","TenantApiMiddlewareFactory","SystemGraphQLContextFactory","SystemApiMiddlewareFactory","ContentSchemaTransferMappingFactory","SystemSchemaTransferMappingFactory","ImportExecutor","ExportExecutor","ImportApiMiddlewareFactory","ExportApiControllerFactory","Application","createColllectHttpMetricsMiddleware","homepageController","HttpResponse","Initializer","ApplicationWorkerManager","createShowMetricsMiddleware"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM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AAY,WAAW,2BAA2B,QAAQ;AACnE,SAAA,SAAS,QAAQ,KAAKC,0BAAAA,kBAAkB;AAExC,SAAA,iBAAiB,YAAY,WAAW,MAAM;AACzC,eAAA,IAAIC,aAAAA,aAAa,KAAK,IAAI;AAAA,MAAA,CACjC;AAAA,IAAA,CACD,EACA,WAAW,eAAe,CAAC,EAAE,sBAC7B,MAAA,IAAIC,YAAY,YAAA,qBAAqB,CAAC,EACtC,WAAW,sBAAsB,MACjC,IAAIC,yBAAAA,0BAA0B,EAC9B,aAAa,6BAA6B,CAAC,IAAI,EAAE,SAAArC,eAAc;AAC/D,iBAAW,UAAUA,UAAS;AAC7B,YAAI,OAAO,2BAA2B;AACrC,aAAG,MAAM,KAAK,OAAO,0BAAA,CAA2B;AAAA,QAAA;AAAA,MACjD;AAAA,IAED,CAAA,EACA,WAAW,iBAAiB,CAAC,EAAE,mBAAmB;AAC5C,YAAA,MAAM,IAAI,IAAI;AAChB,UAAA,IAAIsC,kDAA4B,YAAY,CAAC;AAE1C,aAAA;AAAA,IAAA,CACP;AAAA,EAAA;AAAA,EAIH,OAAO,MAA4C;AAClD,UAAM,YAAY,KAAK,cAAc,IAAI,EAAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;;"}
|
|
@@ -11,7 +11,6 @@ import { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFacto
|
|
|
11
11
|
import { createProviders } from "./providers.js";
|
|
12
12
|
import { TenantApiMiddlewareFactory } from "./tenant/TenantApiMiddlewareFactory.js";
|
|
13
13
|
import { TenantGraphQLHandlerFactory } from "./tenant/TenantGraphQLHandlerFactory.js";
|
|
14
|
-
import { TenantGraphQLContextFactory } from "./tenant/TenantGraphQLContextFactory.js";
|
|
15
14
|
import { SystemApiMiddlewareFactory } from "./system/SystemApiMiddlewareFactory.js";
|
|
16
15
|
import { SystemGraphQLContextFactory } from "./system/SystemGraphQLContextFactory.js";
|
|
17
16
|
import { SystemGraphQLHandlerFactory } from "./system/SystemGraphQLHandlerFactory.js";
|
|
@@ -82,7 +81,7 @@ class MasterContainerFactory {
|
|
|
82
81
|
serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : void 0,
|
|
83
82
|
projectGroupContainerResolver
|
|
84
83
|
);
|
|
85
|
-
}).addService("notModifiedChecker", () => new NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers, executionContainerFactory }) => new ContentGraphQLContextFactory(providers, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("
|
|
84
|
+
}).addService("notModifiedChecker", () => new NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers, executionContainerFactory }) => new ContentGraphQLContextFactory(providers, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
|
|
86
85
|
const app = new Application(
|
|
87
86
|
projectGroupResolver,
|
|
88
87
|
serverConfig2,
|