create-rudder-app 1.4.0 → 1.5.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.
- package/README.md +2 -51
- package/bin/index.mjs +18 -0
- package/package.json +8 -28
- package/dist/agent-detect.d.ts +0 -21
- package/dist/agent-detect.d.ts.map +0 -1
- package/dist/agent-detect.js +0 -36
- package/dist/agent-detect.js.map +0 -1
- package/dist/cli-flags.d.ts +0 -60
- package/dist/cli-flags.d.ts.map +0 -1
- package/dist/cli-flags.js +0 -251
- package/dist/cli-flags.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -642
- package/dist/index.js.map +0 -1
- package/dist/logo.d.ts +0 -6
- package/dist/logo.d.ts.map +0 -1
- package/dist/logo.js +0 -52
- package/dist/logo.js.map +0 -1
- package/dist/templates/app/auth-controller.d.ts +0 -2
- package/dist/templates/app/auth-controller.d.ts.map +0 -1
- package/dist/templates/app/auth-controller.js +0 -53
- package/dist/templates/app/auth-controller.js.map +0 -1
- package/dist/templates/app/mcp-echo-server.d.ts +0 -2
- package/dist/templates/app/mcp-echo-server.d.ts.map +0 -1
- package/dist/templates/app/mcp-echo-server.js +0 -13
- package/dist/templates/app/mcp-echo-server.js.map +0 -1
- package/dist/templates/app/mcp-echo-tool.d.ts +0 -2
- package/dist/templates/app/mcp-echo-tool.d.ts.map +0 -1
- package/dist/templates/app/mcp-echo-tool.js +0 -20
- package/dist/templates/app/mcp-echo-tool.js.map +0 -1
- package/dist/templates/app/service-provider.d.ts +0 -3
- package/dist/templates/app/service-provider.d.ts.map +0 -1
- package/dist/templates/app/service-provider.js +0 -33
- package/dist/templates/app/service-provider.js.map +0 -1
- package/dist/templates/app/terminal-dashboard.d.ts +0 -2
- package/dist/templates/app/terminal-dashboard.d.ts.map +0 -1
- package/dist/templates/app/terminal-dashboard.js +0 -22
- package/dist/templates/app/terminal-dashboard.js.map +0 -1
- package/dist/templates/app/user-model.d.ts +0 -2
- package/dist/templates/app/user-model.d.ts.map +0 -1
- package/dist/templates/app/user-model.js +0 -19
- package/dist/templates/app/user-model.js.map +0 -1
- package/dist/templates/bootstrap/app.d.ts +0 -3
- package/dist/templates/bootstrap/app.d.ts.map +0 -1
- package/dist/templates/bootstrap/app.js +0 -41
- package/dist/templates/bootstrap/app.js.map +0 -1
- package/dist/templates/bootstrap/providers.d.ts +0 -3
- package/dist/templates/bootstrap/providers.d.ts.map +0 -1
- package/dist/templates/bootstrap/providers.js +0 -27
- package/dist/templates/bootstrap/providers.js.map +0 -1
- package/dist/templates/components/site-header.d.ts +0 -4
- package/dist/templates/components/site-header.d.ts.map +0 -1
- package/dist/templates/components/site-header.js +0 -233
- package/dist/templates/components/site-header.js.map +0 -1
- package/dist/templates/configs/ai.d.ts +0 -2
- package/dist/templates/configs/ai.d.ts.map +0 -1
- package/dist/templates/configs/ai.js +0 -32
- package/dist/templates/configs/ai.js.map +0 -1
- package/dist/templates/configs/app.d.ts +0 -2
- package/dist/templates/configs/app.d.ts.map +0 -1
- package/dist/templates/configs/app.js +0 -12
- package/dist/templates/configs/app.js.map +0 -1
- package/dist/templates/configs/auth.d.ts +0 -3
- package/dist/templates/configs/auth.d.ts.map +0 -1
- package/dist/templates/configs/auth.js +0 -16
- package/dist/templates/configs/auth.js.map +0 -1
- package/dist/templates/configs/cache.d.ts +0 -2
- package/dist/templates/configs/cache.d.ts.map +0 -1
- package/dist/templates/configs/cache.js +0 -28
- package/dist/templates/configs/cache.js.map +0 -1
- package/dist/templates/configs/crypt.d.ts +0 -2
- package/dist/templates/configs/crypt.d.ts.map +0 -1
- package/dist/templates/configs/crypt.js +0 -16
- package/dist/templates/configs/crypt.js.map +0 -1
- package/dist/templates/configs/database.d.ts +0 -3
- package/dist/templates/configs/database.d.ts.map +0 -1
- package/dist/templates/configs/database.js +0 -28
- package/dist/templates/configs/database.js.map +0 -1
- package/dist/templates/configs/hash.d.ts +0 -2
- package/dist/templates/configs/hash.d.ts.map +0 -1
- package/dist/templates/configs/hash.js +0 -12
- package/dist/templates/configs/hash.js.map +0 -1
- package/dist/templates/configs/horizon.d.ts +0 -2
- package/dist/templates/configs/horizon.d.ts.map +0 -1
- package/dist/templates/configs/horizon.js +0 -30
- package/dist/templates/configs/horizon.js.map +0 -1
- package/dist/templates/configs/index.d.ts +0 -3
- package/dist/templates/configs/index.d.ts.map +0 -1
- package/dist/templates/configs/index.js +0 -92
- package/dist/templates/configs/index.js.map +0 -1
- package/dist/templates/configs/localization.d.ts +0 -2
- package/dist/templates/configs/localization.d.ts.map +0 -1
- package/dist/templates/configs/localization.js +0 -13
- package/dist/templates/configs/localization.js.map +0 -1
- package/dist/templates/configs/log.d.ts +0 -2
- package/dist/templates/configs/log.d.ts.map +0 -1
- package/dist/templates/configs/log.js +0 -40
- package/dist/templates/configs/log.js.map +0 -1
- package/dist/templates/configs/mail.d.ts +0 -2
- package/dist/templates/configs/mail.d.ts.map +0 -1
- package/dist/templates/configs/mail.js +0 -33
- package/dist/templates/configs/mail.js.map +0 -1
- package/dist/templates/configs/passport.d.ts +0 -2
- package/dist/templates/configs/passport.d.ts.map +0 -1
- package/dist/templates/configs/passport.js +0 -22
- package/dist/templates/configs/passport.js.map +0 -1
- package/dist/templates/configs/pennant.d.ts +0 -2
- package/dist/templates/configs/pennant.d.ts.map +0 -1
- package/dist/templates/configs/pennant.js +0 -16
- package/dist/templates/configs/pennant.js.map +0 -1
- package/dist/templates/configs/pulse.d.ts +0 -2
- package/dist/templates/configs/pulse.d.ts.map +0 -1
- package/dist/templates/configs/pulse.js +0 -21
- package/dist/templates/configs/pulse.js.map +0 -1
- package/dist/templates/configs/queue.d.ts +0 -2
- package/dist/templates/configs/queue.d.ts.map +0 -1
- package/dist/templates/configs/queue.js +0 -28
- package/dist/templates/configs/queue.js.map +0 -1
- package/dist/templates/configs/sanctum.d.ts +0 -2
- package/dist/templates/configs/sanctum.d.ts.map +0 -1
- package/dist/templates/configs/sanctum.js +0 -19
- package/dist/templates/configs/sanctum.js.map +0 -1
- package/dist/templates/configs/server.d.ts +0 -2
- package/dist/templates/configs/server.d.ts.map +0 -1
- package/dist/templates/configs/server.js +0 -15
- package/dist/templates/configs/server.js.map +0 -1
- package/dist/templates/configs/session.d.ts +0 -2
- package/dist/templates/configs/session.d.ts.map +0 -1
- package/dist/templates/configs/session.js +0 -26
- package/dist/templates/configs/session.js.map +0 -1
- package/dist/templates/configs/socialite.d.ts +0 -2
- package/dist/templates/configs/socialite.d.ts.map +0 -1
- package/dist/templates/configs/socialite.js +0 -27
- package/dist/templates/configs/socialite.js.map +0 -1
- package/dist/templates/configs/storage.d.ts +0 -2
- package/dist/templates/configs/storage.d.ts.map +0 -1
- package/dist/templates/configs/storage.js +0 -35
- package/dist/templates/configs/storage.js.map +0 -1
- package/dist/templates/configs/sync.d.ts +0 -3
- package/dist/templates/configs/sync.d.ts.map +0 -1
- package/dist/templates/configs/sync.js +0 -17
- package/dist/templates/configs/sync.js.map +0 -1
- package/dist/templates/configs/telescope.d.ts +0 -2
- package/dist/templates/configs/telescope.d.ts.map +0 -1
- package/dist/templates/configs/telescope.js +0 -25
- package/dist/templates/configs/telescope.js.map +0 -1
- package/dist/templates/css/index.d.ts +0 -3
- package/dist/templates/css/index.d.ts.map +0 -1
- package/dist/templates/css/index.js +0 -140
- package/dist/templates/css/index.js.map +0 -1
- package/dist/templates/css/plain.d.ts +0 -2
- package/dist/templates/css/plain.d.ts.map +0 -1
- package/dist/templates/css/plain.js +0 -373
- package/dist/templates/css/plain.js.map +0 -1
- package/dist/templates/css/tailwind.d.ts +0 -2
- package/dist/templates/css/tailwind.d.ts.map +0 -1
- package/dist/templates/css/tailwind.js +0 -176
- package/dist/templates/css/tailwind.js.map +0 -1
- package/dist/templates/env.d.ts +0 -7
- package/dist/templates/env.d.ts.map +0 -1
- package/dist/templates/env.js +0 -113
- package/dist/templates/env.js.map +0 -1
- package/dist/templates/package-json.d.ts +0 -3
- package/dist/templates/package-json.d.ts.map +0 -1
- package/dist/templates/package-json.js +0 -204
- package/dist/templates/package-json.js.map +0 -1
- package/dist/templates/package-managers.d.ts +0 -14
- package/dist/templates/package-managers.d.ts.map +0 -1
- package/dist/templates/package-managers.js +0 -49
- package/dist/templates/package-managers.js.map +0 -1
- package/dist/templates/pages/ai-chat.d.ts +0 -7
- package/dist/templates/pages/ai-chat.d.ts.map +0 -1
- package/dist/templates/pages/ai-chat.js +0 -285
- package/dist/templates/pages/ai-chat.js.map +0 -1
- package/dist/templates/pages/demo.d.ts +0 -4
- package/dist/templates/pages/demo.d.ts.map +0 -1
- package/dist/templates/pages/demo.js +0 -71
- package/dist/templates/pages/demo.js.map +0 -1
- package/dist/templates/pages/error.d.ts +0 -7
- package/dist/templates/pages/error.d.ts.map +0 -1
- package/dist/templates/pages/error.js +0 -148
- package/dist/templates/pages/error.js.map +0 -1
- package/dist/templates/pages/index.d.ts +0 -22
- package/dist/templates/pages/index.d.ts.map +0 -1
- package/dist/templates/pages/index.js +0 -374
- package/dist/templates/pages/index.js.map +0 -1
- package/dist/templates/prisma/auth.d.ts +0 -2
- package/dist/templates/prisma/auth.d.ts.map +0 -1
- package/dist/templates/prisma/auth.js +0 -22
- package/dist/templates/prisma/auth.js.map +0 -1
- package/dist/templates/prisma/base.d.ts +0 -3
- package/dist/templates/prisma/base.d.ts.map +0 -1
- package/dist/templates/prisma/base.js +0 -14
- package/dist/templates/prisma/base.js.map +0 -1
- package/dist/templates/prisma/config.d.ts +0 -3
- package/dist/templates/prisma/config.d.ts.map +0 -1
- package/dist/templates/prisma/config.js +0 -15
- package/dist/templates/prisma/config.js.map +0 -1
- package/dist/templates/prisma/notification.d.ts +0 -2
- package/dist/templates/prisma/notification.d.ts.map +0 -1
- package/dist/templates/prisma/notification.js +0 -16
- package/dist/templates/prisma/notification.js.map +0 -1
- package/dist/templates/prisma/passport.d.ts +0 -2
- package/dist/templates/prisma/passport.d.ts.map +0 -1
- package/dist/templates/prisma/passport.js +0 -69
- package/dist/templates/prisma/passport.js.map +0 -1
- package/dist/templates/routes/api.d.ts +0 -3
- package/dist/templates/routes/api.d.ts.map +0 -1
- package/dist/templates/routes/api.js +0 -76
- package/dist/templates/routes/api.js.map +0 -1
- package/dist/templates/routes/console.d.ts +0 -3
- package/dist/templates/routes/console.d.ts.map +0 -1
- package/dist/templates/routes/console.js +0 -29
- package/dist/templates/routes/console.js.map +0 -1
- package/dist/templates/routes/web.d.ts +0 -4
- package/dist/templates/routes/web.d.ts.map +0 -1
- package/dist/templates/routes/web.js +0 -77
- package/dist/templates/routes/web.js.map +0 -1
- package/dist/templates/routes-manifest.d.ts +0 -28
- package/dist/templates/routes-manifest.d.ts.map +0 -1
- package/dist/templates/routes-manifest.js +0 -48
- package/dist/templates/routes-manifest.js.map +0 -1
- package/dist/templates/server.d.ts +0 -2
- package/dist/templates/server.d.ts.map +0 -1
- package/dist/templates/server.js +0 -10
- package/dist/templates/server.js.map +0 -1
- package/dist/templates/tsconfig.d.ts +0 -3
- package/dist/templates/tsconfig.d.ts.map +0 -1
- package/dist/templates/tsconfig.js +0 -33
- package/dist/templates/tsconfig.js.map +0 -1
- package/dist/templates/views/welcome.d.ts +0 -19
- package/dist/templates/views/welcome.d.ts.map +0 -1
- package/dist/templates/views/welcome.js +0 -338
- package/dist/templates/views/welcome.js.map +0 -1
- package/dist/templates/vite.d.ts +0 -3
- package/dist/templates/vite.d.ts.map +0 -1
- package/dist/templates/vite.js +0 -66
- package/dist/templates/vite.js.map +0 -1
- package/dist/templates.d.ts +0 -45
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -202
- package/dist/templates.js.map +0 -1
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
export function pagesRootConfig(ctx) {
|
|
2
|
-
// No-frontend recipe (api-service / minimal). No vike-* renderer installed,
|
|
3
|
-
// so Vike auto-discovers an adjacent `+onRenderHtml.ts` (scaffolded next to
|
|
4
|
-
// this file — see `pagesRootRenderHtml`). Vike rejects `onRenderHtml`
|
|
5
|
-
// declared inline in +config.ts ("runtime in config" error), so the hook
|
|
6
|
-
// must live in its own file.
|
|
7
|
-
if (ctx.frameworks.length === 0) {
|
|
8
|
-
return `import type { Config } from 'vike/types'
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
passToClient: ['user', 'locale', 'flash'],
|
|
12
|
-
} satisfies Config
|
|
13
|
-
`;
|
|
14
|
-
}
|
|
15
|
-
// Forward @rudderjs/vite pageContext enhancers (user/locale/flash) to the
|
|
16
|
-
// client during hydration. Without this, components reading
|
|
17
|
-
// pageContext.user via usePageContext() render signed-in on the server but
|
|
18
|
-
// signed-out on the client, causing a hydration flicker.
|
|
19
|
-
if (ctx.frameworks.length === 1) {
|
|
20
|
-
const rendererImport = ctx.primary === 'vue'
|
|
21
|
-
? `import vikeVue from 'vike-vue/config'`
|
|
22
|
-
: ctx.primary === 'solid'
|
|
23
|
-
? `import vikeSolid from 'vike-solid/config'`
|
|
24
|
-
: `import vikeReact from 'vike-react/config'`;
|
|
25
|
-
const rendererVar = ctx.primary === 'vue' ? 'vikeVue' : ctx.primary === 'solid' ? 'vikeSolid' : 'vikeReact';
|
|
26
|
-
return `import type { Config } from 'vike/types'
|
|
27
|
-
${rendererImport}
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
extends: [${rendererVar}],
|
|
31
|
-
passToClient: ['user', 'locale', 'flash'],
|
|
32
|
-
} satisfies Config
|
|
33
|
-
`;
|
|
34
|
-
}
|
|
35
|
-
// Multi-framework: no renderer in root config — each page picks its own.
|
|
36
|
-
// No `extends` here, so the workaround isn't needed.
|
|
37
|
-
return `import type { Config } from 'vike/types'
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
passToClient: ['user', 'locale', 'flash'],
|
|
41
|
-
} satisfies Config
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
export function pagesIndexConfig(ctx) {
|
|
45
|
-
switch (ctx.primary) {
|
|
46
|
-
case 'vue':
|
|
47
|
-
return `import type { Config } from 'vike/types'
|
|
48
|
-
import vikeVue from 'vike-vue/config'
|
|
49
|
-
|
|
50
|
-
export default {
|
|
51
|
-
extends: vikeVue,
|
|
52
|
-
} satisfies Config
|
|
53
|
-
`;
|
|
54
|
-
case 'solid':
|
|
55
|
-
return `import type { Config } from 'vike/types'
|
|
56
|
-
import vikeSolid from 'vike-solid/config'
|
|
57
|
-
|
|
58
|
-
export default {
|
|
59
|
-
extends: vikeSolid,
|
|
60
|
-
} satisfies Config
|
|
61
|
-
`;
|
|
62
|
-
default: // react
|
|
63
|
-
return `import type { Config } from 'vike/types'
|
|
64
|
-
import vikeReact from 'vike-react/config'
|
|
65
|
-
|
|
66
|
-
export default {
|
|
67
|
-
extends: vikeReact,
|
|
68
|
-
} satisfies Config
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export function pagesIndexData(ctx) {
|
|
73
|
-
if (!ctx.packages.auth) {
|
|
74
|
-
return `export type Data = {
|
|
75
|
-
message: string
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function data(): Promise<Data> {
|
|
79
|
-
return { message: 'Welcome to RudderJS' }
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
}
|
|
83
|
-
return `import { app } from '@rudderjs/core'
|
|
84
|
-
import { AuthManager, Auth, runWithAuth } from '@rudderjs/auth'
|
|
85
|
-
|
|
86
|
-
export type Data = {
|
|
87
|
-
user: { id: string; name: string; email: string } | null
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export async function data(): Promise<Data> {
|
|
91
|
-
const manager = app().make<AuthManager>('auth.manager')
|
|
92
|
-
let user: Data['user'] = null
|
|
93
|
-
await runWithAuth(manager, async () => {
|
|
94
|
-
const authUser = await Auth.user()
|
|
95
|
-
if (authUser) {
|
|
96
|
-
const record = authUser as unknown as Record<string, unknown>
|
|
97
|
-
user = {
|
|
98
|
-
id: String(authUser.getAuthIdentifier()),
|
|
99
|
-
name: String(record['name'] ?? ''),
|
|
100
|
-
email: String(record['email'] ?? ''),
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
return { user }
|
|
105
|
-
}
|
|
106
|
-
`;
|
|
107
|
-
}
|
|
108
|
-
export function pagesIndexPage(ctx) {
|
|
109
|
-
switch (ctx.primary) {
|
|
110
|
-
case 'vue': return pagesIndexPageVue(ctx);
|
|
111
|
-
case 'solid': return pagesIndexPageSolid(ctx);
|
|
112
|
-
default: return pagesIndexPageReact(ctx);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export function pagesIndexPageReact(ctx) {
|
|
116
|
-
const cssImport = `import '@/index.css'\n`;
|
|
117
|
-
const extraLinks = [];
|
|
118
|
-
if (ctx.packages.ai)
|
|
119
|
-
extraLinks.push(' <a href="/ai-chat" className="auth-link">AI Chat</a>');
|
|
120
|
-
const extraLinksStr = extraLinks.length > 0 ? '\n' + extraLinks.join('\n') : '';
|
|
121
|
-
if (!ctx.packages.auth) {
|
|
122
|
-
return `${cssImport}import { useData } from 'vike-react/useData'
|
|
123
|
-
import type { Data } from './+data.js'
|
|
124
|
-
|
|
125
|
-
export default function Page() {
|
|
126
|
-
const data = useData<Data>()
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<div className="error-wrap">
|
|
130
|
-
<h1 className="heading-lg">${ctx.name}</h1>
|
|
131
|
-
<p className="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
132
|
-
|
|
133
|
-
<div className="footer-links muted">
|
|
134
|
-
<a href="/api/health" className="auth-link">API Health</a>${extraLinksStr}
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
return `${cssImport}import { useState } from 'react'
|
|
142
|
-
import { useData } from 'vike-react/useData'
|
|
143
|
-
import { getCsrfToken } from '@rudderjs/middleware/client'
|
|
144
|
-
import type { Data } from './+data.js'
|
|
145
|
-
|
|
146
|
-
export default function Page() {
|
|
147
|
-
const data = useData<Data>()
|
|
148
|
-
const [user, setUser] = useState(data.user)
|
|
149
|
-
|
|
150
|
-
async function signOut() {
|
|
151
|
-
await fetch('/auth/sign-out', {
|
|
152
|
-
method: 'POST',
|
|
153
|
-
headers: {
|
|
154
|
-
'Content-Type': 'application/json',
|
|
155
|
-
'X-CSRF-Token': getCsrfToken(),
|
|
156
|
-
},
|
|
157
|
-
body: '{}',
|
|
158
|
-
})
|
|
159
|
-
window.location.href = '/'
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<div className="error-wrap">
|
|
164
|
-
<h1 className="heading-lg">${ctx.name}</h1>
|
|
165
|
-
<p className="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
166
|
-
|
|
167
|
-
{user ? (
|
|
168
|
-
<>
|
|
169
|
-
<p className="nav-badge">
|
|
170
|
-
Signed in as <strong>{user.name}</strong>
|
|
171
|
-
</p>
|
|
172
|
-
<div className="footer-links">
|
|
173
|
-
<button onClick={signOut} className="nav-button">Sign out</button>
|
|
174
|
-
</div>
|
|
175
|
-
</>
|
|
176
|
-
) : (
|
|
177
|
-
<div className="footer-links">
|
|
178
|
-
<a href="/register" className="nav-button">Register</a>
|
|
179
|
-
<a href="/login" className="nav-button">Login</a>
|
|
180
|
-
</div>
|
|
181
|
-
)}
|
|
182
|
-
|
|
183
|
-
<div className="footer-links muted">
|
|
184
|
-
<a href="/api/health" className="auth-link">API Health</a>
|
|
185
|
-
<a href="/api/me" className="auth-link">Session Info</a>${extraLinksStr}
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
`;
|
|
191
|
-
}
|
|
192
|
-
export function pagesIndexPageVue(ctx) {
|
|
193
|
-
const cssImport = `import '@/index.css'\n`;
|
|
194
|
-
const extraLinks = [];
|
|
195
|
-
if (ctx.packages.ai)
|
|
196
|
-
extraLinks.push(' <a href="/ai-chat" class="auth-link">AI Chat</a>');
|
|
197
|
-
const extraStr = extraLinks.length > 0 ? '\n' + extraLinks.join('\n') : '';
|
|
198
|
-
if (!ctx.packages.auth) {
|
|
199
|
-
return `<script setup lang="ts">
|
|
200
|
-
${cssImport}import { useData } from 'vike-vue/useData'
|
|
201
|
-
import type { Data } from './+data.js'
|
|
202
|
-
|
|
203
|
-
const data = useData<Data>()
|
|
204
|
-
</script>
|
|
205
|
-
|
|
206
|
-
<template>
|
|
207
|
-
<div class="error-wrap">
|
|
208
|
-
<h1 class="heading-lg">${ctx.name}</h1>
|
|
209
|
-
<p class="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
210
|
-
|
|
211
|
-
<div class="footer-links muted">
|
|
212
|
-
<a href="/api/health" class="auth-link">API Health</a>${extraStr}
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
</template>
|
|
216
|
-
`;
|
|
217
|
-
}
|
|
218
|
-
return `<script setup lang="ts">
|
|
219
|
-
${cssImport}import { ref } from 'vue'
|
|
220
|
-
import { useData } from 'vike-vue/useData'
|
|
221
|
-
import { getCsrfToken } from '@rudderjs/middleware/client'
|
|
222
|
-
import type { Data } from './+data.js'
|
|
223
|
-
|
|
224
|
-
const data = useData<Data>()
|
|
225
|
-
const user = ref(data.user)
|
|
226
|
-
|
|
227
|
-
async function signOut() {
|
|
228
|
-
await fetch('/auth/sign-out', {
|
|
229
|
-
method: 'POST',
|
|
230
|
-
headers: {
|
|
231
|
-
'Content-Type': 'application/json',
|
|
232
|
-
'X-CSRF-Token': getCsrfToken(),
|
|
233
|
-
},
|
|
234
|
-
body: '{}',
|
|
235
|
-
})
|
|
236
|
-
window.location.href = '/'
|
|
237
|
-
}
|
|
238
|
-
</script>
|
|
239
|
-
|
|
240
|
-
<template>
|
|
241
|
-
<div class="error-wrap">
|
|
242
|
-
<h1 class="heading-lg">${ctx.name}</h1>
|
|
243
|
-
<p class="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
244
|
-
|
|
245
|
-
<template v-if="user">
|
|
246
|
-
<p class="nav-badge">
|
|
247
|
-
Signed in as <strong>{{ user.name }}</strong>
|
|
248
|
-
</p>
|
|
249
|
-
<div class="footer-links">
|
|
250
|
-
<button @click="signOut" class="nav-button">Sign out</button>
|
|
251
|
-
</div>
|
|
252
|
-
</template>
|
|
253
|
-
<div v-else class="footer-links">
|
|
254
|
-
<a href="/register" class="nav-button">Register</a>
|
|
255
|
-
<a href="/login" class="nav-button">Login</a>
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
<div class="footer-links muted">
|
|
259
|
-
<a href="/api/health" class="auth-link">API Health</a>
|
|
260
|
-
<a href="/api/me" class="auth-link">Session Info</a>${extraStr}
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
</template>
|
|
264
|
-
`;
|
|
265
|
-
}
|
|
266
|
-
export function pagesIndexPageSolid(ctx) {
|
|
267
|
-
const cssImport = `import '@/index.css'\n`;
|
|
268
|
-
const extraLinks = [];
|
|
269
|
-
if (ctx.packages.ai)
|
|
270
|
-
extraLinks.push(' <a href="/ai-chat" class="auth-link">AI Chat</a>');
|
|
271
|
-
const extraStr = extraLinks.length > 0 ? '\n' + extraLinks.join('\n') : '';
|
|
272
|
-
if (!ctx.packages.auth) {
|
|
273
|
-
return `${cssImport}import { useData } from 'vike-solid/useData'
|
|
274
|
-
import type { Data } from './+data.js'
|
|
275
|
-
|
|
276
|
-
export default function Page() {
|
|
277
|
-
const data = useData<Data>()
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<div class="error-wrap">
|
|
281
|
-
<h1 class="heading-lg">${ctx.name}</h1>
|
|
282
|
-
<p class="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
283
|
-
|
|
284
|
-
<div class="footer-links muted">
|
|
285
|
-
<a href="/api/health" class="auth-link">API Health</a>${extraStr}
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
)
|
|
289
|
-
}
|
|
290
|
-
`;
|
|
291
|
-
}
|
|
292
|
-
return `${cssImport}import { createSignal, Show } from 'solid-js'
|
|
293
|
-
import { useData } from 'vike-solid/useData'
|
|
294
|
-
import { getCsrfToken } from '@rudderjs/middleware/client'
|
|
295
|
-
import type { Data } from './+data.js'
|
|
296
|
-
|
|
297
|
-
export default function Page() {
|
|
298
|
-
const data = useData<Data>()
|
|
299
|
-
const [user, setUser] = createSignal(data.user)
|
|
300
|
-
|
|
301
|
-
async function signOut() {
|
|
302
|
-
await fetch('/auth/sign-out', {
|
|
303
|
-
method: 'POST',
|
|
304
|
-
headers: {
|
|
305
|
-
'Content-Type': 'application/json',
|
|
306
|
-
'X-CSRF-Token': getCsrfToken(),
|
|
307
|
-
},
|
|
308
|
-
body: '{}',
|
|
309
|
-
})
|
|
310
|
-
window.location.href = '/'
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<div class="error-wrap">
|
|
315
|
-
<h1 class="heading-lg">${ctx.name}</h1>
|
|
316
|
-
<p class="muted">Built with RudderJS — Laravel-inspired Node.js framework.</p>
|
|
317
|
-
|
|
318
|
-
<Show
|
|
319
|
-
when={user()}
|
|
320
|
-
fallback={
|
|
321
|
-
<div class="footer-links">
|
|
322
|
-
<a href="/register" class="nav-button">Register</a>
|
|
323
|
-
<a href="/login" class="nav-button">Login</a>
|
|
324
|
-
</div>
|
|
325
|
-
}
|
|
326
|
-
>
|
|
327
|
-
<p class="nav-badge">
|
|
328
|
-
Signed in as <strong>{user()!.name}</strong>
|
|
329
|
-
</p>
|
|
330
|
-
<div class="footer-links">
|
|
331
|
-
<button onClick={signOut} class="nav-button">Sign out</button>
|
|
332
|
-
</div>
|
|
333
|
-
</Show>
|
|
334
|
-
|
|
335
|
-
<div class="footer-links muted">
|
|
336
|
-
<a href="/api/health" class="auth-link">API Health</a>
|
|
337
|
-
<a href="/api/me" class="auth-link">Session Info</a>${extraStr}
|
|
338
|
-
</div>
|
|
339
|
-
</div>
|
|
340
|
-
)
|
|
341
|
-
}
|
|
342
|
-
`;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Vanilla `+onRenderHtml.ts` for no-frontend recipes (api-service, minimal).
|
|
346
|
-
*
|
|
347
|
-
* Vike auto-discovers this file adjacent to `+config.ts` and uses it as the
|
|
348
|
-
* render hook when no vike-* renderer is installed. The page's `Page` export
|
|
349
|
-
* (generated by @rudderjs/vite's scanner from app/Views/Welcome.ts) returns
|
|
350
|
-
* a string body fragment, and this hook wraps it in the document shell.
|
|
351
|
-
*
|
|
352
|
-
* Vike rejects `onRenderHtml` defined inline in `+config.ts` — runtime code
|
|
353
|
-
* (like a render hook) must live in its own file. See
|
|
354
|
-
* https://vike.dev/error/runtime-in-config.
|
|
355
|
-
*/
|
|
356
|
-
export function pagesRootRenderHtml() {
|
|
357
|
-
return `import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
|
358
|
-
|
|
359
|
-
export default async function onRenderHtml(pageContext: unknown): Promise<unknown> {
|
|
360
|
-
const ctx = pageContext as { Page: (pc: unknown) => string }
|
|
361
|
-
const body = ctx.Page(pageContext)
|
|
362
|
-
return escapeInject\`<!DOCTYPE html>
|
|
363
|
-
<html lang="en">
|
|
364
|
-
<head>
|
|
365
|
-
<meta charset="UTF-8" />
|
|
366
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
367
|
-
<title>RudderJS</title>
|
|
368
|
-
</head>
|
|
369
|
-
<body>\${dangerouslySkipEscape(body)}</body>
|
|
370
|
-
</html>\`
|
|
371
|
-
}
|
|
372
|
-
`;
|
|
373
|
-
}
|
|
374
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/pages/index.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,GAAoB;IAClD,4EAA4E;IAC5E,4EAA4E;IAC5E,sEAAsE;IACtE,yEAAyE;IACzE,6BA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/templates/prisma/auth.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,IAAI,MAAM,CAoBnC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function prismaAuth() {
|
|
2
|
-
return `model User {
|
|
3
|
-
id String @id @default(cuid())
|
|
4
|
-
name String
|
|
5
|
-
email String @unique
|
|
6
|
-
password String?
|
|
7
|
-
emailVerifiedAt DateTime?
|
|
8
|
-
image String?
|
|
9
|
-
role String @default("user")
|
|
10
|
-
rememberToken String?
|
|
11
|
-
createdAt DateTime @default(now())
|
|
12
|
-
updatedAt DateTime @updatedAt
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
model PasswordResetToken {
|
|
16
|
-
email String @id
|
|
17
|
-
token String
|
|
18
|
-
createdAt DateTime @default(now())
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/templates/prisma/auth.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU;IACxB,OAAO;;;;;;;;;;;;;;;;;;CAkBR,CAAA;AACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/templates/prisma/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAavD"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function prismaBase(ctx) {
|
|
2
|
-
const provider = ctx.db === 'sqlite' ? 'sqlite'
|
|
3
|
-
: ctx.db === 'postgresql' ? 'postgresql'
|
|
4
|
-
: 'mysql';
|
|
5
|
-
return `generator client {
|
|
6
|
-
provider = "prisma-client-js"
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
datasource db {
|
|
10
|
-
provider = "${provider}"
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/templates/prisma/base.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,GAAoB;IAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ;QAC7C,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY;YACxC,CAAC,CAAC,OAAO,CAAA;IAEX,OAAO;;;;;gBAKO,QAAQ;;CAEvB,CAAA;AACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/templates/prisma/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAczD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function prismaConfig(ctx) {
|
|
2
|
-
const dbUrl = ctx.db === 'sqlite'
|
|
3
|
-
? "process.env['DATABASE_URL'] ?? 'file:./dev.db'"
|
|
4
|
-
: "process.env['DATABASE_URL']!";
|
|
5
|
-
return `import { defineConfig } from 'prisma/config'
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
schema: 'prisma/schema',
|
|
9
|
-
datasource: {
|
|
10
|
-
url: ${dbUrl},
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
`;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/templates/prisma/config.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAoB;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,KAAK,QAAQ;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,8BAA8B,CAAA;IAElC,OAAO;;;;;WAKE,KAAK;;;CAGf,CAAA;AACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../../src/templates/prisma/notification.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,IAAI,MAAM,CAc3C"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function prismaNotification() {
|
|
2
|
-
return `model Notification {
|
|
3
|
-
id String @id @default(cuid())
|
|
4
|
-
notifiable_id String
|
|
5
|
-
notifiable_type String
|
|
6
|
-
type String
|
|
7
|
-
data String
|
|
8
|
-
read_at String?
|
|
9
|
-
created_at String
|
|
10
|
-
updated_at String
|
|
11
|
-
|
|
12
|
-
@@index([notifiable_type, notifiable_id])
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=notification.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../src/templates/prisma/notification.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;CAYR,CAAA;AACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passport.d.ts","sourceRoot":"","sources":["../../../src/templates/prisma/passport.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,IAAI,MAAM,CAmEvC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export function prismaPassport() {
|
|
2
|
-
return `model OAuthClient {
|
|
3
|
-
id String @id @default(cuid())
|
|
4
|
-
name String
|
|
5
|
-
secret String?
|
|
6
|
-
redirectUris String @default("[]")
|
|
7
|
-
grantTypes String @default("[\\"authorization_code\\"]")
|
|
8
|
-
scopes String @default("[]")
|
|
9
|
-
confidential Boolean @default(true)
|
|
10
|
-
revoked Boolean @default(false)
|
|
11
|
-
createdAt DateTime @default(now())
|
|
12
|
-
updatedAt DateTime @updatedAt
|
|
13
|
-
|
|
14
|
-
@@map("oauth_clients")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
model OAuthAccessToken {
|
|
18
|
-
id String @id @default(cuid())
|
|
19
|
-
userId String?
|
|
20
|
-
clientId String
|
|
21
|
-
name String?
|
|
22
|
-
scopes String @default("[]")
|
|
23
|
-
revoked Boolean @default(false)
|
|
24
|
-
expiresAt DateTime
|
|
25
|
-
createdAt DateTime @default(now())
|
|
26
|
-
|
|
27
|
-
@@index([userId])
|
|
28
|
-
@@map("oauth_access_tokens")
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
model OAuthRefreshToken {
|
|
32
|
-
id String @id @default(cuid())
|
|
33
|
-
accessTokenId String @unique
|
|
34
|
-
revoked Boolean @default(false)
|
|
35
|
-
expiresAt DateTime
|
|
36
|
-
|
|
37
|
-
@@map("oauth_refresh_tokens")
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
model OAuthAuthCode {
|
|
41
|
-
id String @id @default(cuid())
|
|
42
|
-
userId String
|
|
43
|
-
clientId String
|
|
44
|
-
scopes String @default("[]")
|
|
45
|
-
revoked Boolean @default(false)
|
|
46
|
-
expiresAt DateTime
|
|
47
|
-
codeChallenge String?
|
|
48
|
-
codeChallengeMethod String?
|
|
49
|
-
|
|
50
|
-
@@map("oauth_auth_codes")
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
model OAuthDeviceCode {
|
|
54
|
-
id String @id @default(cuid())
|
|
55
|
-
clientId String
|
|
56
|
-
userCode String @unique
|
|
57
|
-
deviceCode String @unique
|
|
58
|
-
scopes String @default("[]")
|
|
59
|
-
userId String?
|
|
60
|
-
approved Boolean?
|
|
61
|
-
expiresAt DateTime
|
|
62
|
-
lastPolledAt DateTime?
|
|
63
|
-
createdAt DateTime @default(now())
|
|
64
|
-
|
|
65
|
-
@@map("oauth_device_codes")
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=passport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passport.js","sourceRoot":"","sources":["../../../src/templates/prisma/passport.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiER,CAAA;AACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/templates/routes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,wBAAgB,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAiFtD"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export function routesApi(ctx) {
|
|
2
|
-
const imports = [
|
|
3
|
-
"import { router } from '@rudderjs/router'",
|
|
4
|
-
];
|
|
5
|
-
const lines = [];
|
|
6
|
-
if (ctx.packages.auth || ctx.packages.ai) {
|
|
7
|
-
imports.push("import { app } from '@rudderjs/core'");
|
|
8
|
-
}
|
|
9
|
-
if (ctx.packages.auth) {
|
|
10
|
-
imports.push("import { Auth, AuthManager, runWithAuth } from '@rudderjs/auth'");
|
|
11
|
-
imports.push("import { SessionMiddleware } from '@rudderjs/session'");
|
|
12
|
-
}
|
|
13
|
-
if (ctx.packages.ai) {
|
|
14
|
-
imports.push("import { AI } from '@rudderjs/ai'");
|
|
15
|
-
}
|
|
16
|
-
lines.push('');
|
|
17
|
-
lines.push("router.get('/api/health', (_req, res) => res.json({ status: 'ok' }))");
|
|
18
|
-
if (ctx.packages.auth) {
|
|
19
|
-
lines.push('');
|
|
20
|
-
lines.push(`// GET /api/me — returns current user or null (Laravel Sanctum SPA-style).
|
|
21
|
-
// Api routes are stateless by default, so session is opted in per-route.
|
|
22
|
-
// Session-mutating handlers (sign-in, sign-up, sign-out, password reset)
|
|
23
|
-
// live in routes/web.ts so they inherit SessionMiddleware from the web group.
|
|
24
|
-
router.get('/api/me', async (req, res) => {
|
|
25
|
-
const manager = app().make<AuthManager>('auth.manager')
|
|
26
|
-
let user: Record<string, unknown> | null = null
|
|
27
|
-
await runWithAuth(manager, async () => {
|
|
28
|
-
const authUser = await Auth.user()
|
|
29
|
-
if (authUser) {
|
|
30
|
-
user = { id: authUser.getAuthIdentifier() }
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
res.json({ user })
|
|
34
|
-
}, [SessionMiddleware()])`);
|
|
35
|
-
}
|
|
36
|
-
if (ctx.packages.ai) {
|
|
37
|
-
lines.push('');
|
|
38
|
-
lines.push(`// POST /api/ai/chat — simple AI chat endpoint
|
|
39
|
-
router.post('/api/ai/chat', async (req, res) => {
|
|
40
|
-
const { messages } = req.body as { messages: { role: string; content: string }[] }
|
|
41
|
-
const lastMessage = messages.at(-1)?.content ?? ''
|
|
42
|
-
const response = await AI.agent('You are a helpful assistant.').prompt(lastMessage)
|
|
43
|
-
res.json({ message: response.text })
|
|
44
|
-
})`);
|
|
45
|
-
}
|
|
46
|
-
if (ctx.packages.passport) {
|
|
47
|
-
imports.push("import { registerPassportRoutes, RequireBearer, scope } from '@rudderjs/passport'");
|
|
48
|
-
lines.push('');
|
|
49
|
-
lines.push(`// ── Passport OAuth 2 routes ──────────────────────────────
|
|
50
|
-
//
|
|
51
|
-
// Registers /oauth/authorize, /oauth/token, /oauth/tokens/:id,
|
|
52
|
-
// /oauth/scopes, /oauth/device/code, /oauth/device/approve.
|
|
53
|
-
//
|
|
54
|
-
// Requires: RSA keys via \`pnpm rudder passport:keys\` and an OAuth client
|
|
55
|
-
// via \`pnpm rudder passport:client <name>\`.
|
|
56
|
-
const passportRouter = {
|
|
57
|
-
get: (path: string, handler: any) => router.get(path, handler),
|
|
58
|
-
post: (path: string, handler: any) => router.post(path, handler),
|
|
59
|
-
delete: (path: string, handler: any) => router.delete(path, handler),
|
|
60
|
-
}
|
|
61
|
-
registerPassportRoutes(passportRouter as any)
|
|
62
|
-
|
|
63
|
-
// Example: protected route requiring a Bearer token with 'read' scope
|
|
64
|
-
router.get('/api/passport/me', async (req, res) => {
|
|
65
|
-
res.json({
|
|
66
|
-
user: req.user ?? null,
|
|
67
|
-
scopes: (req.raw as any)?.__passport_scopes ?? [],
|
|
68
|
-
})
|
|
69
|
-
}, [RequireBearer(), scope('read')])`);
|
|
70
|
-
}
|
|
71
|
-
lines.push('');
|
|
72
|
-
lines.push("// Catch-all: any unmatched /api/* route returns 404");
|
|
73
|
-
lines.push("router.all('/api/*', (_req, res) => res.status(404).json({ message: 'Route not found.' }))");
|
|
74
|
-
return imports.join('\n') + '\n' + lines.join('\n') + '\n';
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=api.js.map
|