@jcbuisson/express-x 1.5.23 → 1.5.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "1.5.23",
3
+ "version": "1.5.24",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/context.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
 
2
2
  export async function getContextConnection(context) {
3
3
  const id = context.params.connectionId
4
- const connection = await context.app.service('Connection')._findUnique({ where: { id }})
4
+ const connection = await context.app.prisma.Connection.findUnique({ where: { id }})
5
5
  return connection
6
6
  }
7
7
 
8
8
  export async function resetConnection(context) {
9
9
  const id = context.params.connectionId
10
- await context.app.service('Connection')._update({
10
+ await context.app.prisma.Connection.update({
11
11
  where: { id },
12
12
  data: {
13
13
  clientIP: '',
@@ -19,17 +19,17 @@ export async function resetConnection(context) {
19
19
 
20
20
  export async function getConnectionDataItem(context, key) {
21
21
  const id = context.params.connectionId
22
- const connection = await context.app.service('Connection')._findUnique({ where: { id }})
22
+ const connection = await context.app.prisma.Connection.findUnique({ where: { id }})
23
23
  const data = JSON.parse(connection.data)
24
24
  return data[key]
25
25
  }
26
26
 
27
27
  export async function setConnectionDataItem(context, key, value) {
28
28
  const id = context.params.connectionId
29
- const connection = await context.app.service('Connection')._findUnique({ where: { id }})
29
+ const connection = await context.app.prisma.Connection.findUnique({ where: { id }})
30
30
  const data = JSON.parse(connection.data)
31
31
  data[key] = value
32
- await context.app.service('Connection')._update({
32
+ await context.app.prisma.Connection.update({
33
33
  where: { id },
34
34
  data: {
35
35
  data: JSON.stringify(data)
@@ -39,10 +39,10 @@ export async function setConnectionDataItem(context, key, value) {
39
39
 
40
40
  export async function removeConnectionDataItem(context, key) {
41
41
  const id = context.params.connectionId
42
- const connection = await context.app.service('Connection')._findUnique({ where: { id }})
42
+ const connection = await context.app.prisma.Connection.findUnique({ where: { id }})
43
43
  const data = JSON.parse(connection.data)
44
44
  delete data[key]
45
- await context.app.service('Connection').update({
45
+ await context.app.prisma.Connection.update({
46
46
  where: { id },
47
47
  data: {
48
48
  data: JSON.stringify(data)
package/src/server.mjs CHANGED
@@ -399,7 +399,7 @@ export function expressX(prisma, options = {}) {
399
399
  }
400
400
 
401
401
  async function getChannelConnections(channelName) {
402
- const connections = await app.service('Connection').findMany({})
402
+ const connections = await app.prisma.Connection.findMany({})
403
403
  return connections.filter(connection => {
404
404
  const channelNames = JSON.parse(connection.channelNames)
405
405
  return channelNames.includes(channelName)
@@ -409,7 +409,7 @@ export function expressX(prisma, options = {}) {
409
409
  async function addChannelToConnection(connection, channelName) {
410
410
  const channelNames = JSON.parse(connection.channelNames)
411
411
  if (!channelNames.includes(channelName)) channelNames.push(channelName)
412
- await app.service('Connection').update({
412
+ await app.prisma.Connection.update({
413
413
  where: { id: connection.id },
414
414
  data: { channelNames: JSON.stringify(channelNames) },
415
415
  })
@@ -417,7 +417,7 @@ export function expressX(prisma, options = {}) {
417
417
 
418
418
  async function removeChannelFromConnection(connection, channelName) {
419
419
  const channelNames = JSON.parse(connection.channelNames).filter(name => name !== channelName)
420
- await app.service('Connection').update({
420
+ await app.prisma.Connection.update({
421
421
  where: { id },
422
422
  data: { channelNames: JSON.stringify(channelNames) },
423
423
  })