@jcbuisson/express-x 1.7.5 → 1.7.6
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/server.mjs +6 -6
package/package.json
CHANGED
package/src/server.mjs
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import http from 'http'
|
|
3
3
|
import { Server } from "socket.io"
|
|
4
4
|
import express from 'express'
|
|
5
|
-
import config from 'config'
|
|
6
5
|
|
|
7
6
|
/*
|
|
8
7
|
* Enhance `app` express application with services and real-time features
|
|
9
8
|
*/
|
|
10
|
-
export function expressX(prisma,
|
|
9
|
+
export function expressX(prisma, config) {
|
|
11
10
|
|
|
12
11
|
const app = express()
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
// websocket transport by default
|
|
14
|
+
if (config.WS_TRANSPORT == undefined) config.WS_TRANSPORT = true
|
|
15
15
|
|
|
16
16
|
const services = {}
|
|
17
17
|
let appHooks = []
|
|
@@ -121,7 +121,7 @@ export function expressX(prisma, options = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// publish event (websocket transport)
|
|
124
|
-
if (
|
|
124
|
+
if (config.WS_TRANSPORT && service.publishFunction) {
|
|
125
125
|
const channelNames = await service.publishFunction(result, app)
|
|
126
126
|
app.log('verbose', `publish channels ${service.name} ${methodName} ${channelNames}`)
|
|
127
127
|
const connections = await app.prisma.Connection.findMany({})
|
|
@@ -312,7 +312,7 @@ export function expressX(prisma, options = {}) {
|
|
|
312
312
|
*/
|
|
313
313
|
const server = new http.Server(app)
|
|
314
314
|
|
|
315
|
-
if (
|
|
315
|
+
if (config.WS_TRANSPORT) {
|
|
316
316
|
/*
|
|
317
317
|
* Add websocket transport
|
|
318
318
|
*/
|
|
@@ -456,7 +456,7 @@ export function expressX(prisma, options = {}) {
|
|
|
456
456
|
// enhance `app` with objects and methods
|
|
457
457
|
return Object.assign(app, {
|
|
458
458
|
prisma,
|
|
459
|
-
|
|
459
|
+
config,
|
|
460
460
|
getSocket, setSocket,
|
|
461
461
|
createDatabaseService,
|
|
462
462
|
createService,
|