@8ms/helpers 2.0.8 → 2.0.9

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.
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.8",
4
+ "version": "2.0.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -41,19 +41,25 @@ class PrismaNamespace extends _class_1.BaseNamespace {
41
41
  // Async setup to only initialise where required
42
42
  this.ensureInit = async () => {
43
43
  if (!this.client) {
44
- try {
45
- const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
46
- let adapter;
47
- if (this.config.isPlanetScale) {
44
+ let adapter;
45
+ if (this.config.isPlanetScale) {
46
+ try {
48
47
  const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
49
48
  adapter = new PrismaPlanetScale({
50
49
  url: this.config.url,
51
50
  });
52
51
  }
52
+ catch (e) {
53
+ throw new Error("PlanetScale Client not installed");
54
+ }
55
+ }
56
+ try {
57
+ const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
53
58
  // Show the full query if debugging
54
59
  if (this.config.isDebug) {
55
60
  this.client = new PrismaClient({
56
61
  adapter,
62
+ datasourceUrl: this.config.url,
57
63
  log: [
58
64
  {
59
65
  emit: "event",
@@ -64,11 +70,14 @@ class PrismaNamespace extends _class_1.BaseNamespace {
64
70
  }
65
71
  // Standard prisma
66
72
  else {
67
- this.client = new PrismaClient({ adapter });
73
+ this.client = new PrismaClient({
74
+ adapter,
75
+ datasourceUrl: this.config.url,
76
+ });
68
77
  }
69
78
  }
70
79
  catch (e) {
71
- throw new Error("Prisma / PlanetScale Client not installed");
80
+ throw new Error("Prisma Client not installed");
72
81
  }
73
82
  }
74
83
  };
package/prisma/server.js CHANGED
@@ -21,6 +21,7 @@ const prismaClient = async (key = "default", config) => {
21
21
  }
22
22
  }
23
23
  const namespace = new PrismaNamespace_1.PrismaNamespace(key, config);
24
+ await namespace.ensureInit();
24
25
  prismaNamespaces.set(key, namespace);
25
26
  return namespace;
26
27
  };