@things-factory/shell 6.1.166 → 6.1.174

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": "@things-factory/shell",
3
- "version": "6.1.166",
3
+ "version": "6.1.174",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -59,10 +59,10 @@
59
59
  "@operato/shell": "^1.0.1",
60
60
  "@operato/typeorm-history": "^1.1.65",
61
61
  "@operato/utils": "^1.0.1",
62
- "@things-factory/ejs-remote": "^6.1.166",
63
- "@things-factory/env": "^6.1.166",
64
- "@things-factory/styles": "^6.1.166",
65
- "@things-factory/utils": "^6.1.166",
62
+ "@things-factory/ejs-remote": "^6.1.174",
63
+ "@things-factory/env": "^6.1.174",
64
+ "@things-factory/styles": "^6.1.174",
65
+ "@things-factory/utils": "^6.1.174",
66
66
  "@webcomponents/webcomponentsjs": "^2.6.0",
67
67
  "args": "^5.0.0",
68
68
  "broadcastchannel-polyfill": "^1.0.1",
@@ -131,5 +131,5 @@
131
131
  "pg": "^8.7.3",
132
132
  "sqlite3": "^5.0.8"
133
133
  },
134
- "gitHead": "911a15cef99960e4d9dcb76df7895dff099d72d1"
134
+ "gitHead": "582dea90062d7298e39e18d3634a7ac3c3a56310"
135
135
  }
@@ -40,8 +40,8 @@ export function initMiddlewares(app) {
40
40
  })
41
41
  }
42
42
 
43
- process.on('bootstrap-module-subscription' as any, (app, subscriptionMiddleware) => {
44
- subscriptionMiddleware.push(domainMiddleware)
45
- })
43
+ // process.on('bootstrap-module-subscription' as any, (app, subscriptionMiddleware) => {
44
+ // subscriptionMiddleware.push(domainMiddleware)
45
+ // })
46
46
 
47
47
  export * from './domain-middleware'
package/server/pubsub.ts CHANGED
@@ -89,6 +89,6 @@ process.on('SIGUSR1', exitHandler.bind(null, { name: 'SIGUSR1', exit: true }))
89
89
  process.on('SIGUSR2', exitHandler.bind(null, { name: 'SIGUSR2', exit: true }))
90
90
 
91
91
  //catches uncaught exceptions
92
- process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }))
92
+ // process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }))
93
93
 
94
94
  export { pubsub }
@@ -21,6 +21,7 @@ import compose from 'koa-compose'
21
21
  import { historyApiFallback } from 'koa2-connect-history-api-fallback'
22
22
  import { WebSocketServer } from 'ws'
23
23
  import co from 'co'
24
+ import http from 'http'
24
25
 
25
26
  import koaWebpack from '@hatiolab/koa-webpack'
26
27
  import cors from '@koa/cors'
@@ -38,9 +39,10 @@ import {
38
39
  import { schema } from './schema'
39
40
  import { Domain } from './service'
40
41
  import { EntityManager } from 'typeorm'
42
+ import { domainMiddleware } from './middlewares'
41
43
 
42
44
  process.on('uncaughtException', error => {
43
- logger.error('uncaughtException: ', error)
45
+ logger.error('uncaughtException: ', error, error.stack)
44
46
 
45
47
  //process.exit(1)
46
48
  })
@@ -88,13 +90,14 @@ interface ICustomAppState {
88
90
 
89
91
  interface ICustomAppContext {
90
92
  t: any
93
+ ssoMiddlewares: any[]
91
94
  }
92
95
 
93
96
  /* bootstrap */
94
97
  const bootstrap = async () => {
95
98
  await databaseInitializer()
96
99
 
97
- const app = new Koa<ICustomAppState, ICustomAppContext>()
100
+ const app = new Koa<ICustomAppState, ICustomAppContext>() as any
98
101
 
99
102
  app.use(
100
103
  cors({
@@ -159,11 +162,11 @@ const bootstrap = async () => {
159
162
  ...(connectionParams['headers'] || (connectionParams as any))
160
163
  }
161
164
 
162
- var koacontext = await app.createContext(request, {} as any)
165
+ var koacontext = await app.createContext(request, new http.ServerResponse(request))
163
166
  koacontext['state'] = {}
164
167
 
165
168
  /* in case connect error(like a authentication error) just throw exception */
166
- var middlewares = [...subscriptionMiddleware]
169
+ var middlewares = [domainMiddleware, ...subscriptionMiddleware]
167
170
  const fn = co.wrap(compose(middlewares))
168
171
 
169
172
  await fn(koacontext)
@@ -247,6 +250,10 @@ const bootstrap = async () => {
247
250
  app.use(koaBodyParser(bodyParserOption))
248
251
 
249
252
  /* routers */
253
+ const ssoMiddlewares = []
254
+ process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)
255
+ app.ssoMiddlewares = ssoMiddlewares
256
+
250
257
  process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)
251
258
  process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)
252
259
  process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)
package/server/server.ts CHANGED
@@ -21,6 +21,7 @@ import compose from 'koa-compose'
21
21
  import { historyApiFallback } from 'koa2-connect-history-api-fallback'
22
22
  import { WebSocketServer } from 'ws'
23
23
  import co from 'co'
24
+ import http from 'http'
24
25
 
25
26
  import cors from '@koa/cors'
26
27
  import { config, loader, logger, orderedModuleNames } from '@things-factory/env'
@@ -35,9 +36,10 @@ import {
35
36
  graphqlRouter
36
37
  } from './routers'
37
38
  import { schema } from './schema'
39
+ import { domainMiddleware } from './middlewares'
38
40
 
39
41
  process.on('uncaughtException', error => {
40
- logger.error('uncaughtException: ', error)
42
+ logger.error('uncaughtException: ', error, error.stack)
41
43
 
42
44
  //process.exit(1)
43
45
  })
@@ -70,7 +72,7 @@ const fileUploadOption = {
70
72
  const bootstrap = async () => {
71
73
  await databaseInitializer()
72
74
 
73
- const app = new Koa()
75
+ const app = new Koa() as any
74
76
 
75
77
  app.use(
76
78
  cors({
@@ -135,11 +137,11 @@ const bootstrap = async () => {
135
137
  ...(connectionParams['headers'] || (connectionParams as any))
136
138
  }
137
139
 
138
- var koacontext = await app.createContext(request, {} as any)
140
+ var koacontext = await app.createContext(request, new http.ServerResponse(request))
139
141
  koacontext['state'] = {}
140
142
 
141
143
  /* in case connect error(like a authentication error) just throw exception */
142
- var middlewares = [...subscriptionMiddleware]
144
+ var middlewares = [domainMiddleware, ...subscriptionMiddleware]
143
145
  const fn = co.wrap(compose(middlewares))
144
146
 
145
147
  await fn(koacontext)
@@ -208,6 +210,10 @@ const bootstrap = async () => {
208
210
  app.use(koaBodyParser(bodyParserOption))
209
211
 
210
212
  /* routers */
213
+ const ssoMiddlewares = []
214
+ process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)
215
+ app.ssoMiddlewares = ssoMiddlewares
216
+
211
217
  process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)
212
218
  process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)
213
219
  process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)