@ossy/app 0.5.12 → 0.6.0

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.
@@ -9,7 +9,7 @@ export function ProxyInternal() {
9
9
 
10
10
  const domain = process.env.OSSY_API_URL || 'https://api.ossy.se'
11
11
  const url = `${domain}${req.originalUrl?.replace('/@ossy', '/api/v0')}`
12
- const headers = JSON.parse(JSON.stringify(req.headers)) // Clone headers
12
+ const headers = { ...(req.headers || {}) } // Clone headers
13
13
  const workspaceId = headers.workspaceId
14
14
 
15
15
  if (workspaceId) {
package/cli/server.js CHANGED
@@ -24,6 +24,29 @@ if (Middleware !== undefined) {
24
24
  const middleware = [
25
25
  morgan('tiny'),
26
26
  express.json({ strict: false }),
27
+ (req, res, next) => {
28
+ const domain = process.env.OSSY_API_URL || 'https://api.ossy.se'
29
+ const url = `${domain}/api/v0/users/me`
30
+ const headers = { ...(req.headers || {}) } // Clone headers
31
+
32
+ const request = {
33
+ method: req.method,
34
+ headers: JSON.parse(JSON.stringify(req.headers))
35
+ }
36
+
37
+ fetch(url, request)
38
+ .then(response => response.json())
39
+ .then((userAppSettings) => {
40
+ req.userAppSettings = userAppSettings || {}
41
+ next()
42
+ })
43
+ .catch((error) => {
44
+ console.log(`[@ossy/app][server][error]`, error)
45
+ req.userAppSettings = {}
46
+ next()
47
+ })
48
+
49
+ },
27
50
  ...(Middleware || []),
28
51
  express.static(ROOT_PATH),
29
52
  ProxyInternal(),
@@ -43,7 +66,9 @@ app.all('/*all', (req, res) => {
43
66
  apiRoute.handle(req, res)
44
67
  }
45
68
 
46
- renderToString(App, { url: req.url })
69
+ const userAppSettings = req.userAppSettings || {}
70
+
71
+ renderToString(App, { url: req.url, theme: userAppSettings.theme || 'light' })
47
72
  .then(html => { res.send(html) })
48
73
  .catch(err => { res.send(err) })
49
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/app",
3
- "version": "0.5.12",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "source": "./src/index.js",
6
6
  "main": "./src/index.js",
@@ -57,5 +57,5 @@
57
57
  "/cli",
58
58
  "README.md"
59
59
  ],
60
- "gitHead": "cb9f97e61ba92e607d4b153538ab66175c29c1ab"
60
+ "gitHead": "eafa7411add27f733b8764e95cb05654b0e38e74"
61
61
  }