@empyria/webui 0.1.21 → 0.1.23
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": "@empyria/webui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "Restate.dev helpers for the Empyria nanoservice framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Imre Fazekas <imre.fazekas@icloud.com>",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"lint:fix": "bun oxlint --fix"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@empyria/common": "0.3.
|
|
27
|
-
"@empyria/moleculer": "0.1.
|
|
28
|
-
"@empyria/restate": "0.4.
|
|
29
|
-
"@iconify-json/lucide": "^1.2.
|
|
30
|
-
"@iconify-json/simple-icons": "^1.2.
|
|
26
|
+
"@empyria/common": "0.3.12",
|
|
27
|
+
"@empyria/moleculer": "0.1.22",
|
|
28
|
+
"@empyria/restate": "0.4.16",
|
|
29
|
+
"@iconify-json/lucide": "^1.2.140",
|
|
30
|
+
"@iconify-json/simple-icons": "^1.2.99",
|
|
31
31
|
"@pinia/nuxt": "^1.0.2",
|
|
32
32
|
"@simplewebauthn/browser": "^14.0.0",
|
|
33
33
|
"@trpc/client": "^11.19.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@vueuse/core": "^15.0.0",
|
|
36
36
|
"@vueuse/nuxt": "^15.0.0",
|
|
37
37
|
"croner": "^10.0.1",
|
|
38
|
-
"cronstrue": "^3.
|
|
38
|
+
"cronstrue": "^3.29.0",
|
|
39
39
|
"moleculer": "0.15.2",
|
|
40
40
|
"ms": "^2.1.3",
|
|
41
41
|
"pinia-plugin-persistedstate": "^4.7.1",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@nuxt/ui": "^4.11.3",
|
|
49
49
|
"@nuxtjs/tailwindcss": "7.0.0-beta.1",
|
|
50
50
|
"@tailwindcss/typography": "^0.5.20",
|
|
51
|
-
"nuxt": "^4.
|
|
51
|
+
"nuxt": "^4.6.0",
|
|
52
|
+
"oxfmt": "0.72.0",
|
|
53
|
+
"oxlint": "1.87.0",
|
|
52
54
|
"tailwindcss": "^4.3.3",
|
|
53
55
|
"typescript": "^7.0.2",
|
|
54
|
-
"vue-tsc": "^3.3.12"
|
|
55
|
-
"oxfmt": "0.71.0",
|
|
56
|
-
"oxlint": "1.86.0"
|
|
56
|
+
"vue-tsc": "^3.3.12"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"bun": ">=1.4.2",
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'
|
|
2
|
+
import { defineEventHandler } from 'nuxt/server'
|
|
2
3
|
import { createContext } from '../../trpc/context'
|
|
3
4
|
import { appRouter } from '../../routers'
|
|
4
5
|
|
|
6
|
+
// The request is already a web `Request` (`event.req`): tRPC's fetch adapter takes it as it is.
|
|
5
7
|
export default defineEventHandler(async (event) => {
|
|
6
|
-
// console.log('✅ Test route hit!')
|
|
7
|
-
|
|
8
|
-
const request = toWebRequest(event)
|
|
9
|
-
|
|
10
8
|
return fetchRequestHandler({
|
|
11
9
|
endpoint: '/api/trpc',
|
|
12
|
-
req:
|
|
10
|
+
req: event.req,
|
|
13
11
|
router: appRouter,
|
|
14
12
|
createContext: () => createContext(event),
|
|
15
13
|
})
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ServiceBroker as MoleculerBroker } from 'moleculer'
|
|
2
2
|
import { randomUUID as uuid } from 'node:crypto'
|
|
3
3
|
import { connect } from '@empyria/moleculer/Connector.js'
|
|
4
|
-
import { getCookie } from 'h3'
|
|
5
|
-
|
|
6
|
-
import { AccessTokenCookieKey } from '../../app/consts'
|
|
7
4
|
|
|
8
5
|
import { settings } from '../env'
|
|
9
6
|
|
|
@@ -89,8 +86,8 @@ export default defineNitroPlugin(async () => {
|
|
|
89
86
|
params?: any,
|
|
90
87
|
opts?: { timeout?: number; meta?: Record<string, any> },
|
|
91
88
|
): Promise<T> {
|
|
92
|
-
|
|
93
|
-
const tokenKey =
|
|
89
|
+
// server/trpc/context.ts puts the login cookie's token on the request's context.
|
|
90
|
+
const tokenKey = useEvent()?.context?.tokenKey
|
|
94
91
|
|
|
95
92
|
if (!whitelistedActions.includes(actionName) && !tokenKey) {
|
|
96
93
|
throw BaseErrors.ServiceVoilation({
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// server/plugins/restate.ts
|
|
2
2
|
import { checkServiceHandler, clients, sendMessage } from '@empyria/restate'
|
|
3
|
-
import { getCookie } from 'h3'
|
|
4
|
-
import { AccessTokenCookieKey } from '../../app/consts'
|
|
5
3
|
|
|
6
4
|
import { settings } from '../env'
|
|
7
5
|
|
|
@@ -20,8 +18,8 @@ export default defineNitroPlugin(() => {
|
|
|
20
18
|
async call<T>(serviceName: string, handlerName: string, params?: any): Promise<T> {
|
|
21
19
|
await checkServiceHandler(restateAdminURL, serviceName, handlerName)
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
const tokenKey =
|
|
21
|
+
// server/trpc/context.ts puts the login cookie's token on the request's context.
|
|
22
|
+
const tokenKey = useEvent()?.context?.tokenKey
|
|
25
23
|
|
|
26
24
|
const paramsWithToken = tokenKey ? { ...params, tokenKey } : params
|
|
27
25
|
|
package/server/trpc/context.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { type CookieSerializeOptions } from 'cookie-es'
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type RequestEvent,
|
|
4
4
|
parseCookies,
|
|
5
5
|
getCookie as getCookieFromEvent,
|
|
6
6
|
setCookie as setCookieOnEvent,
|
|
7
7
|
deleteCookie as deleteCookieOnEvent,
|
|
8
|
-
} from '
|
|
8
|
+
} from 'nuxt/server'
|
|
9
9
|
import { AccessTokenCookieKey } from '../../app/consts'
|
|
10
10
|
|
|
11
|
-
export const createContext = async (event:
|
|
11
|
+
export const createContext = async (event: RequestEvent) => {
|
|
12
12
|
const getCookie = (name: string) => getCookieFromEvent(event, name)
|
|
13
13
|
const setCookie = (name: string, value: string, serializeOptions?: CookieSerializeOptions) =>
|
|
14
14
|
setCookieOnEvent(event, name, value, serializeOptions)
|
|
15
15
|
const deleteCookie = (name: string, serializeOptions?: CookieSerializeOptions) =>
|
|
16
16
|
deleteCookieOnEvent(event, name, serializeOptions)
|
|
17
17
|
|
|
18
|
+
// Kept on the event's context, which every shape of the event shares, for code that runs later in the same request
|
|
19
|
+
// (server/plugins/restate.ts reads it to pass the token on to Restate).
|
|
18
20
|
const tokenKey = getCookie(AccessTokenCookieKey)
|
|
19
21
|
if (tokenKey) {
|
|
20
22
|
event.context.tokenKey = tokenKey
|
|
@@ -26,7 +28,7 @@ export const createContext = async (event: H3Event) => {
|
|
|
26
28
|
getCookie,
|
|
27
29
|
setCookie,
|
|
28
30
|
deleteCookie,
|
|
29
|
-
headers: event.headers,
|
|
31
|
+
headers: event.req.headers,
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|