runlify 0.0.330 → 0.0.331
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/build/projectsGeneration/generators/fileTemplates/back/environment/src/clients/getPrisma.js
CHANGED
|
@@ -7,7 +7,7 @@ var prismaGetterTmpl = function (options) {
|
|
|
7
7
|
if (options === void 0) { options = types_1.defaultBootstrapEntityOptions; }
|
|
8
8
|
return "import {PrismaClient} from '@prisma/client';\nimport {getConfig} from '../config';\nimport log from '../log';\nimport {addParamsToDatabaseUri} from '../utils/addParamsToPgUri';\n".concat(options.skipWarningThisIsGenerated
|
|
9
9
|
? ''
|
|
10
|
-
: "\n// ".concat(utils_1.generatedWarning, "\n"), "\nlet prisma: PrismaClient | null = null;\n\nexport const getPrisma = async (connectionType: 'write' | 'readOnly') => {\n const {\n databaseMainWriteUri,\n databaseMainReadOnlyUri,\n databaseMainReadOnlyEnabled,\n } = await getConfig();\n\n let uri: string;\n\n if (connectionType === 'write') {\n uri = databaseMainWriteUri;\n } else {\n if (!databaseMainReadOnlyEnabled) {\n
|
|
10
|
+
: "\n// ".concat(utils_1.generatedWarning, "\n"), "\nlet prisma: PrismaClient | null = null;\n\nexport const getPrisma = async (connectionType: 'write' | 'readOnly') => {\n const {\n databaseMainWriteUri,\n databaseMainReadOnlyUri,\n databaseMainReadOnlyEnabled,\n } = await getConfig();\n\n let uri: string;\n\n if (connectionType === 'write') {\n uri = databaseMainWriteUri;\n } else {\n if (!databaseMainReadOnlyEnabled) {\n const msg = 'Read only database connection cannot be used with the database.main.readOnly.enabled is not true';\n return new Proxy({} as any, {\n get(_target: PrismaClient, property: string | symbol) {\n if (property === 'then') {\n return undefined;\n }\n\n log.error(`get: ${property.toString()}`);\n\n log.error(msg);\n throw new Error(msg);\n },\n apply: () => {\n log.error('apply');\n log.error(msg);\n throw new Error(msg);\n },\n }) as PrismaClient;\n }\n\n if (!databaseMainReadOnlyUri) {\n throw new Error('database.main.readOnly.uri must be set');\n }\n\n uri = databaseMainReadOnlyUri;\n }\n\n log.info(typeof addParamsToDatabaseUri);\n\n // const url = addParamsToDatabaseUri(databaseMainWriteUri, {\n // application_name: appName,\n // ...(process.env.NODE_ENV === 'production' ? {} : {connection_limit: '1'}),\n // });\n\n if (!prisma) {\n prisma = new PrismaClient({\n datasources: {\n db: {\n url: uri,\n },\n },\n });\n }\n\n return prisma;\n};\n");
|
|
11
11
|
};
|
|
12
12
|
exports.prismaGetterTmpl = prismaGetterTmpl;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0UHJpc21hLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3Byb2plY3RzR2VuZXJhdGlvbi9nZW5lcmF0b3JzL2ZpbGVUZW1wbGF0ZXMvYmFjay9lbnZpcm9ubWVudC9zcmMvY2xpZW50cy9nZXRQcmlzbWEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaURBR2dDO0FBQ2hDLGlEQUEwRDtBQUVuRCxJQUFNLGdCQUFnQixHQUFHLFVBQzlCLE9BQStEO0lBQS9ELHdCQUFBLEVBQUEsVUFBa0MscUNBQTZCO0lBQzVELE9BQUEsNExBS0gsT0FBTyxDQUFDLDBCQUEwQjtRQUNoQyxDQUFDLENBQUMsRUFBRTtRQUNKLENBQUMsQ0FBQyxlQUNELHdCQUFnQixPQUNwQix5aERBK0RBO0FBeEVJLENBd0VKLENBQUE7QUExRVksUUFBQSxnQkFBZ0Isb0JBMEU1QiJ9
|