runlify 0.0.212 → 0.0.214
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.
|
@@ -5,9 +5,9 @@ var types_1 = require("../../../../../types");
|
|
|
5
5
|
var utils_1 = require("../../../../../utils");
|
|
6
6
|
var environmentIndexTmpl = function (options) {
|
|
7
7
|
if (options === void 0) { options = types_1.defaultBootstrapEntityOptions; }
|
|
8
|
-
return "import {exitHook} from './utils/exitHook';\nimport
|
|
8
|
+
return "import {exitHook} from './utils/exitHook';\nimport log from './log';\nimport {createContext} from './adm/services/context';\nimport express, {RequestHandler} from 'express';\nimport cors from 'cors';\nimport passport from 'passport';\nimport {json, raw} from 'body-parser';\nimport restRouter from './rest/restRouter';\nimport helmet from 'helmet';\nimport {collectDefaultMetrics, register} from 'prom-client';\nimport {initAdmPassport} from './adm/config/passport';".concat(options.usersEnabled ? "\nimport {initAppPassport} from './app/config/passport';\nimport appAuthRouter from './app/authRouter';\nimport getAppServer from './app/getAppServer';" : '', "\nimport admAuthRouter from './adm/authRouter';\nimport {graphqlUploadExpress} from 'graphql-upload';\nimport defaultContainer from './adm/services/defaultContainer';\nimport healthRouter from './rest/healthRouter';\nimport expressPlayground from 'graphql-playground-middleware-express';\nimport getAdmServer from './adm/getAdmServer';\n").concat(options.skipWarningThisIsGenerated
|
|
9
9
|
? ''
|
|
10
|
-
: "\n// ".concat(utils_1.generatedWarning, "\n"), "\nexitHook(async () => {\n createContext().then(ctx => ctx.close());\n});\n\nconst app = express();\n").concat(options.usersEnabled ? "\ninitAppPassport();" : '', "\ninitAdmPassport();\n\nconst production = process.env.NODE_ENV === 'production';\nlog.info(`production: ${production}`);\n\napp.use(cors());\napp.use(raw({limit: '50mb'}) as RequestHandler);\napp.use(json({limit: '1mb'}) as RequestHandler);\napp.use(\n helmet(\n {\n contentSecurityPolicy: production ? undefined : false,\n crossOriginEmbedderPolicy: production ? undefined : false,\n },\n ) as RequestHandler,\n);\napp.use(passport.initialize() as RequestHandler);\n").concat(options.usersEnabled ? "\napp.use('/app/rest', appAuthRouter);" : '', "\napp.use('/adm/rest', admAuthRouter);\n\ncollectDefaultMetrics();\n\napp.get('/metrics', async (_req, res) => {\n try {\n res.set('Content-Type', register.contentType);\n res.end(await register.metrics());\n } catch (error: any) {\n res.status(500).end(error);\n }\n});\n\napp.use('/rest', restRouter);\n\napp.use('/health', healthRouter);\n\
|
|
10
|
+
: "\n// ".concat(utils_1.generatedWarning, "\n"), "\nexitHook(async () => {\n createContext().then(ctx => ctx.close());\n});\n\nconst app = express();\n").concat(options.usersEnabled ? "\ninitAppPassport();" : '', "\ninitAdmPassport();\n\nconst production = process.env.NODE_ENV === 'production';\nlog.info(`production: ${production}`);\n\napp.use(cors());\napp.use(raw({limit: '50mb'}) as RequestHandler);\napp.use(json({limit: '1mb'}) as RequestHandler);\napp.use(\n helmet(\n {\n contentSecurityPolicy: production ? undefined : false,\n crossOriginEmbedderPolicy: production ? undefined : false,\n },\n ) as RequestHandler,\n);\napp.use(passport.initialize() as RequestHandler);\n").concat(options.usersEnabled ? "\napp.use('/app/rest', appAuthRouter);" : '', "\napp.use('/adm/rest', admAuthRouter);\n\ncollectDefaultMetrics();\n\napp.get('/metrics', async (_req, res) => {\n try {\n res.set('Content-Type', register.contentType);\n res.end(await register.metrics());\n } catch (error: any) {\n res.status(500).end(error);\n }\n});\n\napp.use('/rest', restRouter);\n\napp.use('/health', healthRouter);\n\nconst start = async () => {\n const context = await createContext(defaultContainer);\n\n app.use('/app/graph', passport.authenticate('appJwt', {session: false}));\n app.use('/app/graph', graphqlUploadExpress({maxFiles: 10, maxFileSize: 50 * 1024 * 1024}) as RequestHandler);\n").concat(options.usersEnabled ? "\n const appServer = getAppServer();\n await appServer.start();\n appServer.applyMiddleware({app, path: '/app/graph'});\n" : '', "\n const admServer = getAdmServer();\n\n const admGraphPath = '/adm/graph';\n app.use(admGraphPath, passport.authenticate('admJwt', {session: false}));\n app.use(admGraphPath, graphqlUploadExpress({maxFiles: 10, maxFileSize: 50 * 1024 * 1024}) as RequestHandler);\n await admServer.start();\n admServer.applyMiddleware({app, path: admGraphPath});\n\n context.service('stats').updateGauges();\n\n const port = 3000;\n const graphEndpoint = `http://localhost:${port}${admServer.graphqlPath}`;\n\n if (!production) {\n app.get(\n '/playground',\n expressPlayground({\n endpoint: graphEndpoint,\n }),\n );\n\n log.info(`\uD83D\uDE80 GraphQL playground at http://localhost:${port}/playground`);\n }\n\n app.listen({port}, () => {\n log.info(`\uD83D\uDE80 Server ready at ${graphEndpoint}`);\n });\n};\n\ntry {\n start();\n} catch (error: any) {\n log.error(error);\n createContext().then(ctx => ctx.close());\n}\n");
|
|
11
11
|
};
|
|
12
12
|
exports.environmentIndexTmpl = environmentIndexTmpl;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvcHJvamVjdHNHZW5lcmF0aW9uL2dlbmVyYXRvcnMvZmlsZVRlbXBsYXRlcy9iYWNrL2Vudmlyb25tZW50L3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4Q0FHNkI7QUFDN0IsOENBQXVEO0FBRWhELElBQU0sb0JBQW9CLEdBQUcsVUFDbEMsT0FBK0Q7SUFBL0Qsd0JBQUEsRUFBQSxVQUFrQyxxQ0FBNkI7SUFDNUQsT0FBQSw0ZEFVbUQsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMseUpBR2hDLENBQUMsQ0FBQyxDQUFDLEVBQUUsOFZBUWxELE9BQU8sQ0FBQywwQkFBMEI7UUFDaEMsQ0FBQyxDQUFDLEVBQUU7UUFDSixDQUFDLENBQUMsZUFDRCx3QkFBZ0IsT0FDcEIsbUhBT0MsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsc0JBQ04sQ0FBQyxDQUFDLENBQUMsRUFBRSxtZkFrQnRCLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDLHdDQUNZLENBQUMsQ0FBQyxDQUFDLEVBQUUsd29CQXVCeEMsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsOEhBSXhCLENBQUMsQ0FBQyxDQUFDLEVBQUUsbThCQW9DTDtBQW5ISSxDQW1ISixDQUFBO0FBckhZLFFBQUEsb0JBQW9CLHdCQXFIaEMifQ==
|