@jcbuisson/express-x 1.0.18 → 1.0.19
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/package.json +1 -1
- package/src/index.mjs +6 -1
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import http from 'http'
|
|
3
3
|
import { Server } from "socket.io"
|
|
4
|
+
import { PrismaClient } from '@prisma/client'
|
|
4
5
|
|
|
5
6
|
/*
|
|
6
7
|
* Enhance `app` express application with Feathers-like services
|
|
@@ -19,7 +20,11 @@ function expressX(app, options={}) {
|
|
|
19
20
|
* create a service `name` based on Prisma table `entity`
|
|
20
21
|
*/
|
|
21
22
|
function createDatabaseService(name, { entity=name, client='prisma' }) {
|
|
22
|
-
|
|
23
|
+
let prisma = app.get('prisma')
|
|
24
|
+
if (!prisma) {
|
|
25
|
+
prisma = new PrismaClient()
|
|
26
|
+
app.set('prisma', prisma)
|
|
27
|
+
}
|
|
23
28
|
|
|
24
29
|
const service = createService(name, {
|
|
25
30
|
create: (data) => {
|