create-rudder 1.4.1 → 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 +23 -5
- package/dist/agent-detect.d.ts +21 -0
- package/dist/agent-detect.d.ts.map +1 -0
- package/dist/agent-detect.js +36 -0
- package/dist/agent-detect.js.map +1 -0
- package/dist/cli-flags.d.ts +60 -0
- package/dist/cli-flags.d.ts.map +1 -0
- package/dist/cli-flags.js +251 -0
- package/dist/cli-flags.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +642 -0
- package/dist/index.js.map +1 -0
- package/dist/logo.d.ts +6 -0
- package/dist/logo.d.ts.map +1 -0
- package/dist/logo.js +52 -0
- package/dist/logo.js.map +1 -0
- package/dist/templates/app/auth-controller.d.ts +2 -0
- package/dist/templates/app/auth-controller.d.ts.map +1 -0
- package/dist/templates/app/auth-controller.js +53 -0
- package/dist/templates/app/auth-controller.js.map +1 -0
- package/dist/templates/app/mcp-echo-server.d.ts +2 -0
- package/dist/templates/app/mcp-echo-server.d.ts.map +1 -0
- package/dist/templates/app/mcp-echo-server.js +13 -0
- package/dist/templates/app/mcp-echo-server.js.map +1 -0
- package/dist/templates/app/mcp-echo-tool.d.ts +2 -0
- package/dist/templates/app/mcp-echo-tool.d.ts.map +1 -0
- package/dist/templates/app/mcp-echo-tool.js +20 -0
- package/dist/templates/app/mcp-echo-tool.js.map +1 -0
- package/dist/templates/app/service-provider.d.ts +3 -0
- package/dist/templates/app/service-provider.d.ts.map +1 -0
- package/dist/templates/app/service-provider.js +33 -0
- package/dist/templates/app/service-provider.js.map +1 -0
- package/dist/templates/app/terminal-dashboard.d.ts +2 -0
- package/dist/templates/app/terminal-dashboard.d.ts.map +1 -0
- package/dist/templates/app/terminal-dashboard.js +22 -0
- package/dist/templates/app/terminal-dashboard.js.map +1 -0
- package/dist/templates/app/user-model.d.ts +2 -0
- package/dist/templates/app/user-model.d.ts.map +1 -0
- package/dist/templates/app/user-model.js +19 -0
- package/dist/templates/app/user-model.js.map +1 -0
- package/dist/templates/bootstrap/app.d.ts +3 -0
- package/dist/templates/bootstrap/app.d.ts.map +1 -0
- package/dist/templates/bootstrap/app.js +41 -0
- package/dist/templates/bootstrap/app.js.map +1 -0
- package/dist/templates/bootstrap/providers.d.ts +3 -0
- package/dist/templates/bootstrap/providers.d.ts.map +1 -0
- package/dist/templates/bootstrap/providers.js +27 -0
- package/dist/templates/bootstrap/providers.js.map +1 -0
- package/dist/templates/components/site-header.d.ts +4 -0
- package/dist/templates/components/site-header.d.ts.map +1 -0
- package/dist/templates/components/site-header.js +233 -0
- package/dist/templates/components/site-header.js.map +1 -0
- package/dist/templates/configs/ai.d.ts +2 -0
- package/dist/templates/configs/ai.d.ts.map +1 -0
- package/dist/templates/configs/ai.js +32 -0
- package/dist/templates/configs/ai.js.map +1 -0
- package/dist/templates/configs/app.d.ts +2 -0
- package/dist/templates/configs/app.d.ts.map +1 -0
- package/dist/templates/configs/app.js +12 -0
- package/dist/templates/configs/app.js.map +1 -0
- package/dist/templates/configs/auth.d.ts +3 -0
- package/dist/templates/configs/auth.d.ts.map +1 -0
- package/dist/templates/configs/auth.js +16 -0
- package/dist/templates/configs/auth.js.map +1 -0
- package/dist/templates/configs/cache.d.ts +2 -0
- package/dist/templates/configs/cache.d.ts.map +1 -0
- package/dist/templates/configs/cache.js +28 -0
- package/dist/templates/configs/cache.js.map +1 -0
- package/dist/templates/configs/crypt.d.ts +2 -0
- package/dist/templates/configs/crypt.d.ts.map +1 -0
- package/dist/templates/configs/crypt.js +16 -0
- package/dist/templates/configs/crypt.js.map +1 -0
- package/dist/templates/configs/database.d.ts +3 -0
- package/dist/templates/configs/database.d.ts.map +1 -0
- package/dist/templates/configs/database.js +28 -0
- package/dist/templates/configs/database.js.map +1 -0
- package/dist/templates/configs/hash.d.ts +2 -0
- package/dist/templates/configs/hash.d.ts.map +1 -0
- package/dist/templates/configs/hash.js +12 -0
- package/dist/templates/configs/hash.js.map +1 -0
- package/dist/templates/configs/horizon.d.ts +2 -0
- package/dist/templates/configs/horizon.d.ts.map +1 -0
- package/dist/templates/configs/horizon.js +30 -0
- package/dist/templates/configs/horizon.js.map +1 -0
- package/dist/templates/configs/index.d.ts +3 -0
- package/dist/templates/configs/index.d.ts.map +1 -0
- package/dist/templates/configs/index.js +92 -0
- package/dist/templates/configs/index.js.map +1 -0
- package/dist/templates/configs/localization.d.ts +2 -0
- package/dist/templates/configs/localization.d.ts.map +1 -0
- package/dist/templates/configs/localization.js +13 -0
- package/dist/templates/configs/localization.js.map +1 -0
- package/dist/templates/configs/log.d.ts +2 -0
- package/dist/templates/configs/log.d.ts.map +1 -0
- package/dist/templates/configs/log.js +40 -0
- package/dist/templates/configs/log.js.map +1 -0
- package/dist/templates/configs/mail.d.ts +2 -0
- package/dist/templates/configs/mail.d.ts.map +1 -0
- package/dist/templates/configs/mail.js +33 -0
- package/dist/templates/configs/mail.js.map +1 -0
- package/dist/templates/configs/passport.d.ts +2 -0
- package/dist/templates/configs/passport.d.ts.map +1 -0
- package/dist/templates/configs/passport.js +22 -0
- package/dist/templates/configs/passport.js.map +1 -0
- package/dist/templates/configs/pennant.d.ts +2 -0
- package/dist/templates/configs/pennant.d.ts.map +1 -0
- package/dist/templates/configs/pennant.js +16 -0
- package/dist/templates/configs/pennant.js.map +1 -0
- package/dist/templates/configs/pulse.d.ts +2 -0
- package/dist/templates/configs/pulse.d.ts.map +1 -0
- package/dist/templates/configs/pulse.js +21 -0
- package/dist/templates/configs/pulse.js.map +1 -0
- package/dist/templates/configs/queue.d.ts +2 -0
- package/dist/templates/configs/queue.d.ts.map +1 -0
- package/dist/templates/configs/queue.js +28 -0
- package/dist/templates/configs/queue.js.map +1 -0
- package/dist/templates/configs/sanctum.d.ts +2 -0
- package/dist/templates/configs/sanctum.d.ts.map +1 -0
- package/dist/templates/configs/sanctum.js +19 -0
- package/dist/templates/configs/sanctum.js.map +1 -0
- package/dist/templates/configs/server.d.ts +2 -0
- package/dist/templates/configs/server.d.ts.map +1 -0
- package/dist/templates/configs/server.js +15 -0
- package/dist/templates/configs/server.js.map +1 -0
- package/dist/templates/configs/session.d.ts +2 -0
- package/dist/templates/configs/session.d.ts.map +1 -0
- package/dist/templates/configs/session.js +26 -0
- package/dist/templates/configs/session.js.map +1 -0
- package/dist/templates/configs/socialite.d.ts +2 -0
- package/dist/templates/configs/socialite.d.ts.map +1 -0
- package/dist/templates/configs/socialite.js +27 -0
- package/dist/templates/configs/socialite.js.map +1 -0
- package/dist/templates/configs/storage.d.ts +2 -0
- package/dist/templates/configs/storage.d.ts.map +1 -0
- package/dist/templates/configs/storage.js +35 -0
- package/dist/templates/configs/storage.js.map +1 -0
- package/dist/templates/configs/sync.d.ts +3 -0
- package/dist/templates/configs/sync.d.ts.map +1 -0
- package/dist/templates/configs/sync.js +17 -0
- package/dist/templates/configs/sync.js.map +1 -0
- package/dist/templates/configs/telescope.d.ts +2 -0
- package/dist/templates/configs/telescope.d.ts.map +1 -0
- package/dist/templates/configs/telescope.js +25 -0
- package/dist/templates/configs/telescope.js.map +1 -0
- package/dist/templates/css/index.d.ts +3 -0
- package/dist/templates/css/index.d.ts.map +1 -0
- package/dist/templates/css/index.js +140 -0
- package/dist/templates/css/index.js.map +1 -0
- package/dist/templates/css/plain.d.ts +2 -0
- package/dist/templates/css/plain.d.ts.map +1 -0
- package/dist/templates/css/plain.js +373 -0
- package/dist/templates/css/plain.js.map +1 -0
- package/dist/templates/css/tailwind.d.ts +2 -0
- package/dist/templates/css/tailwind.d.ts.map +1 -0
- package/dist/templates/css/tailwind.js +176 -0
- package/dist/templates/css/tailwind.js.map +1 -0
- package/dist/templates/env.d.ts +7 -0
- package/dist/templates/env.d.ts.map +1 -0
- package/dist/templates/env.js +113 -0
- package/dist/templates/env.js.map +1 -0
- package/dist/templates/package-json.d.ts +3 -0
- package/dist/templates/package-json.d.ts.map +1 -0
- package/dist/templates/package-json.js +204 -0
- package/dist/templates/package-json.js.map +1 -0
- package/dist/templates/package-managers.d.ts +14 -0
- package/dist/templates/package-managers.d.ts.map +1 -0
- package/dist/templates/package-managers.js +49 -0
- package/dist/templates/package-managers.js.map +1 -0
- package/dist/templates/pages/ai-chat.d.ts +7 -0
- package/dist/templates/pages/ai-chat.d.ts.map +1 -0
- package/dist/templates/pages/ai-chat.js +285 -0
- package/dist/templates/pages/ai-chat.js.map +1 -0
- package/dist/templates/pages/demo.d.ts +4 -0
- package/dist/templates/pages/demo.d.ts.map +1 -0
- package/dist/templates/pages/demo.js +71 -0
- package/dist/templates/pages/demo.js.map +1 -0
- package/dist/templates/pages/error.d.ts +7 -0
- package/dist/templates/pages/error.d.ts.map +1 -0
- package/dist/templates/pages/error.js +148 -0
- package/dist/templates/pages/error.js.map +1 -0
- package/dist/templates/pages/index.d.ts +22 -0
- package/dist/templates/pages/index.d.ts.map +1 -0
- package/dist/templates/pages/index.js +374 -0
- package/dist/templates/pages/index.js.map +1 -0
- package/dist/templates/prisma/auth.d.ts +2 -0
- package/dist/templates/prisma/auth.d.ts.map +1 -0
- package/dist/templates/prisma/auth.js +22 -0
- package/dist/templates/prisma/auth.js.map +1 -0
- package/dist/templates/prisma/base.d.ts +3 -0
- package/dist/templates/prisma/base.d.ts.map +1 -0
- package/dist/templates/prisma/base.js +14 -0
- package/dist/templates/prisma/base.js.map +1 -0
- package/dist/templates/prisma/config.d.ts +3 -0
- package/dist/templates/prisma/config.d.ts.map +1 -0
- package/dist/templates/prisma/config.js +15 -0
- package/dist/templates/prisma/config.js.map +1 -0
- package/dist/templates/prisma/notification.d.ts +2 -0
- package/dist/templates/prisma/notification.d.ts.map +1 -0
- package/dist/templates/prisma/notification.js +16 -0
- package/dist/templates/prisma/notification.js.map +1 -0
- package/dist/templates/prisma/passport.d.ts +2 -0
- package/dist/templates/prisma/passport.d.ts.map +1 -0
- package/dist/templates/prisma/passport.js +69 -0
- package/dist/templates/prisma/passport.js.map +1 -0
- package/dist/templates/routes/api.d.ts +3 -0
- package/dist/templates/routes/api.d.ts.map +1 -0
- package/dist/templates/routes/api.js +76 -0
- package/dist/templates/routes/api.js.map +1 -0
- package/dist/templates/routes/console.d.ts +3 -0
- package/dist/templates/routes/console.d.ts.map +1 -0
- package/dist/templates/routes/console.js +29 -0
- package/dist/templates/routes/console.js.map +1 -0
- package/dist/templates/routes/web.d.ts +4 -0
- package/dist/templates/routes/web.d.ts.map +1 -0
- package/dist/templates/routes/web.js +77 -0
- package/dist/templates/routes/web.js.map +1 -0
- package/dist/templates/routes-manifest.d.ts +28 -0
- package/dist/templates/routes-manifest.d.ts.map +1 -0
- package/dist/templates/routes-manifest.js +48 -0
- package/dist/templates/routes-manifest.js.map +1 -0
- package/dist/templates/server.d.ts +2 -0
- package/dist/templates/server.d.ts.map +1 -0
- package/dist/templates/server.js +10 -0
- package/dist/templates/server.js.map +1 -0
- package/dist/templates/tsconfig.d.ts +3 -0
- package/dist/templates/tsconfig.d.ts.map +1 -0
- package/dist/templates/tsconfig.js +33 -0
- package/dist/templates/tsconfig.js.map +1 -0
- package/dist/templates/views/welcome.d.ts +19 -0
- package/dist/templates/views/welcome.d.ts.map +1 -0
- package/dist/templates/views/welcome.js +338 -0
- package/dist/templates/views/welcome.js.map +1 -0
- package/dist/templates/vite.d.ts +3 -0
- package/dist/templates/vite.d.ts.map +1 -0
- package/dist/templates/vite.js +66 -0
- package/dist/templates/vite.js.map +1 -0
- package/dist/templates.d.ts +45 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +202 -0
- package/dist/templates.js.map +1 -0
- package/package.json +27 -7
- package/bin/index.mjs +0 -18
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export function demoPageConfig(fw) {
|
|
2
|
+
switch (fw) {
|
|
3
|
+
case 'vue':
|
|
4
|
+
return `import type { Config } from 'vike/types'
|
|
5
|
+
import vikeVue from 'vike-vue/config'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
extends: vikeVue,
|
|
9
|
+
} satisfies Config
|
|
10
|
+
`;
|
|
11
|
+
case 'solid':
|
|
12
|
+
return `import type { Config } from 'vike/types'
|
|
13
|
+
import vikeSolid from 'vike-solid/config'
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
extends: vikeSolid,
|
|
17
|
+
} satisfies Config
|
|
18
|
+
`;
|
|
19
|
+
default: // react
|
|
20
|
+
return `import type { Config } from 'vike/types'
|
|
21
|
+
import vikeReact from 'vike-react/config'
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
extends: vikeReact,
|
|
25
|
+
} satisfies Config
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function demoPage(fw, ctx) {
|
|
30
|
+
const { primary } = ctx;
|
|
31
|
+
switch (fw) {
|
|
32
|
+
case 'react':
|
|
33
|
+
return `export default function Page() {
|
|
34
|
+
return (
|
|
35
|
+
<div className="error-wrap">
|
|
36
|
+
<h1 className="heading-lg">Hello from React</h1>
|
|
37
|
+
<p className="muted">React demo page — running alongside ${primary}.</p>
|
|
38
|
+
<a href="/" className="auth-link muted">← Back to home</a>
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
case 'vue':
|
|
44
|
+
return `<script setup lang="ts">
|
|
45
|
+
import '@/index.css'
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<div class="error-wrap">
|
|
50
|
+
<h1 class="heading-lg">Hello from Vue</h1>
|
|
51
|
+
<p class="muted">Vue demo page — running alongside ${primary}.</p>
|
|
52
|
+
<a href="/" class="auth-link muted">← Back to home</a>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
`;
|
|
56
|
+
case 'solid':
|
|
57
|
+
return `import '@/index.css'
|
|
58
|
+
|
|
59
|
+
export default function Page() {
|
|
60
|
+
return (
|
|
61
|
+
<div class="error-wrap">
|
|
62
|
+
<h1 class="heading-lg">Hello from Solid</h1>
|
|
63
|
+
<p class="muted">Solid demo page — running alongside ${primary}.</p>
|
|
64
|
+
<a href="/" class="auth-link muted">← Back to home</a>
|
|
65
|
+
</div>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../../src/templates/pages/demo.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAAC,EAA6B;IAC1D,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,KAAK;YACR,OAAO;;;;;;CAMZ,CAAA;QACG,KAAK,OAAO;YACV,OAAO;;;;;;CAMZ,CAAA;QACG,SAAS,QAAQ;YACf,OAAO;;;;;;CAMZ,CAAA;IACC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,EAA6B,EAAE,GAAoB;IAC1E,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;IAEvB,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,OAAO;YACV,OAAO;;;;iEAIoD,OAAO;;;;;CAKvE,CAAA;QAEG,KAAK,KAAK;YACR,OAAO;;;;;;;yDAO4C,OAAO;;;;CAI/D,CAAA;QAEG,KAAK,OAAO;YACV,OAAO;;;;;;6DAMgD,OAAO;;;;;CAKnE,CAAA;IACC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TemplateContext } from '../../templates.js';
|
|
2
|
+
export declare function pagesErrorConfig(ctx: TemplateContext): string;
|
|
3
|
+
export declare function pagesErrorPage(ctx: TemplateContext): string;
|
|
4
|
+
export declare function pagesErrorPageReact(ctx: TemplateContext): string;
|
|
5
|
+
export declare function pagesErrorPageVue(ctx: TemplateContext): string;
|
|
6
|
+
export declare function pagesErrorPageSolid(ctx: TemplateContext): string;
|
|
7
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/templates/pages/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA2B7D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAM3D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAwChE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA8B9D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAuChE"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export function pagesErrorConfig(ctx) {
|
|
2
|
+
switch (ctx.primary) {
|
|
3
|
+
case 'vue':
|
|
4
|
+
return `import type { Config } from 'vike/types'
|
|
5
|
+
import vikeVue from 'vike-vue/config'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
extends: vikeVue,
|
|
9
|
+
} satisfies Config
|
|
10
|
+
`;
|
|
11
|
+
case 'solid':
|
|
12
|
+
return `import type { Config } from 'vike/types'
|
|
13
|
+
import vikeSolid from 'vike-solid/config'
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
extends: vikeSolid,
|
|
17
|
+
} satisfies Config
|
|
18
|
+
`;
|
|
19
|
+
default:
|
|
20
|
+
return `import type { Config } from 'vike/types'
|
|
21
|
+
import vikeReact from 'vike-react/config'
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
extends: vikeReact,
|
|
25
|
+
} satisfies Config
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function pagesErrorPage(ctx) {
|
|
30
|
+
switch (ctx.primary) {
|
|
31
|
+
case 'vue': return pagesErrorPageVue(ctx);
|
|
32
|
+
case 'solid': return pagesErrorPageSolid(ctx);
|
|
33
|
+
default: return pagesErrorPageReact(ctx);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function pagesErrorPageReact(ctx) {
|
|
37
|
+
const cssImport = `import '@/index.css'\n`;
|
|
38
|
+
return `${cssImport}import { usePageContext } from 'vike-react/usePageContext'
|
|
39
|
+
|
|
40
|
+
export default function Page() {
|
|
41
|
+
const { is404, abortReason, abortStatusCode } = usePageContext() as {
|
|
42
|
+
is404: boolean
|
|
43
|
+
abortStatusCode?: number
|
|
44
|
+
abortReason?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (is404) {
|
|
48
|
+
return (
|
|
49
|
+
<div className="error-wrap">
|
|
50
|
+
<h1 className="heading-lg">404 — Page Not Found</h1>
|
|
51
|
+
<p className="muted">This page could not be found.</p>
|
|
52
|
+
<a href="/" className="error-link">Go home</a>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (abortStatusCode === 401) {
|
|
58
|
+
return (
|
|
59
|
+
<div className="error-wrap">
|
|
60
|
+
<h1 className="heading-lg">401 — Unauthorized</h1>
|
|
61
|
+
<p className="muted">{abortReason ?? 'You must be logged in to view this page.'}</p>
|
|
62
|
+
<a href="/" className="error-link">Go home</a>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className="error-wrap">
|
|
69
|
+
<h1 className="heading-lg">Something went wrong</h1>
|
|
70
|
+
<p className="muted">{abortReason ?? 'An unexpected error occurred.'}</p>
|
|
71
|
+
<a href="/" className="error-link">Go home</a>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
export function pagesErrorPageVue(ctx) {
|
|
78
|
+
const cssImport = `import '@/index.css'\n`;
|
|
79
|
+
return `<script setup lang="ts">
|
|
80
|
+
${cssImport}import { usePageContext } from 'vike-vue/usePageContext'
|
|
81
|
+
|
|
82
|
+
const pageContext = usePageContext() as {
|
|
83
|
+
is404: boolean
|
|
84
|
+
abortStatusCode?: number
|
|
85
|
+
abortReason?: string
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<div v-if="pageContext.is404" class="error-wrap">
|
|
91
|
+
<h1 class="heading-lg">404 — Page Not Found</h1>
|
|
92
|
+
<p class="muted">This page could not be found.</p>
|
|
93
|
+
<a href="/" class="error-link">Go home</a>
|
|
94
|
+
</div>
|
|
95
|
+
<div v-else-if="pageContext.abortStatusCode === 401" class="error-wrap">
|
|
96
|
+
<h1 class="heading-lg">401 — Unauthorized</h1>
|
|
97
|
+
<p class="muted">{{ pageContext.abortReason ?? 'You must be logged in to view this page.' }}</p>
|
|
98
|
+
<a href="/" class="error-link">Go home</a>
|
|
99
|
+
</div>
|
|
100
|
+
<div v-else class="error-wrap">
|
|
101
|
+
<h1 class="heading-lg">Something went wrong</h1>
|
|
102
|
+
<p class="muted">{{ pageContext.abortReason ?? 'An unexpected error occurred.' }}</p>
|
|
103
|
+
<a href="/" class="error-link">Go home</a>
|
|
104
|
+
</div>
|
|
105
|
+
</template>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
export function pagesErrorPageSolid(ctx) {
|
|
109
|
+
const cssImport = `import '@/index.css'\n`;
|
|
110
|
+
return `${cssImport}import { Switch, Match } from 'solid-js'
|
|
111
|
+
import { usePageContext } from 'vike-solid/usePageContext'
|
|
112
|
+
|
|
113
|
+
export default function Page() {
|
|
114
|
+
const pageContext = usePageContext() as {
|
|
115
|
+
is404: boolean
|
|
116
|
+
abortStatusCode?: number
|
|
117
|
+
abortReason?: string
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Switch>
|
|
122
|
+
<Match when={pageContext.is404}>
|
|
123
|
+
<div class="error-wrap">
|
|
124
|
+
<h1 class="heading-lg">404 — Page Not Found</h1>
|
|
125
|
+
<p class="muted">This page could not be found.</p>
|
|
126
|
+
<a href="/" class="error-link">Go home</a>
|
|
127
|
+
</div>
|
|
128
|
+
</Match>
|
|
129
|
+
<Match when={pageContext.abortStatusCode === 401}>
|
|
130
|
+
<div class="error-wrap">
|
|
131
|
+
<h1 class="heading-lg">401 — Unauthorized</h1>
|
|
132
|
+
<p class="muted">{pageContext.abortReason ?? 'You must be logged in to view this page.'}</p>
|
|
133
|
+
<a href="/" class="error-link">Go home</a>
|
|
134
|
+
</div>
|
|
135
|
+
</Match>
|
|
136
|
+
<Match when={true}>
|
|
137
|
+
<div class="error-wrap">
|
|
138
|
+
<h1 class="heading-lg">Something went wrong</h1>
|
|
139
|
+
<p class="muted">{pageContext.abortReason ?? 'An unexpected error occurred.'}</p>
|
|
140
|
+
<a href="/" class="error-link">Go home</a>
|
|
141
|
+
</div>
|
|
142
|
+
</Match>
|
|
143
|
+
</Switch>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/templates/pages/error.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,GAAoB;IACnD,QAAQ,GAAG,CAAC,OAAO,EAAE,CAAC;QACpB,KAAK,KAAK;YACR,OAAO;;;;;;CAMZ,CAAA;QACG,KAAK,OAAO;YACV,OAAO;;;;;;CAMZ,CAAA;QACG;YACE,OAAO;;;;;;CAMZ,CAAA;IACC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAoB;IACjD,QAAQ,GAAG,CAAC,OAAO,EAAE,CAAC;QACpB,KAAK,KAAK,CAAC,CAAG,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAA;QAC3C,KAAK,OAAO,CAAC,CAAC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAA;QAC7C,OAAO,CAAC,CAAM,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,MAAM,SAAS,GAAG,wBAAwB,CAAA;IAC1C,OAAO,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCpB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAoB;IACpD,MAAM,SAAS,GAAG,wBAAwB,CAAA;IAC1C,OAAO;EACP,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BV,CAAA;AACD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,MAAM,SAAS,GAAG,wBAAwB,CAAA;IAC1C,OAAO,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCpB,CAAA;AACD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TemplateContext } from '../../templates.js';
|
|
2
|
+
export declare function pagesRootConfig(ctx: TemplateContext): string;
|
|
3
|
+
export declare function pagesIndexConfig(ctx: TemplateContext): string;
|
|
4
|
+
export declare function pagesIndexData(ctx: TemplateContext): string;
|
|
5
|
+
export declare function pagesIndexPage(ctx: TemplateContext): string;
|
|
6
|
+
export declare function pagesIndexPageReact(ctx: TemplateContext): string;
|
|
7
|
+
export declare function pagesIndexPageVue(ctx: TemplateContext): string;
|
|
8
|
+
export declare function pagesIndexPageSolid(ctx: TemplateContext): string;
|
|
9
|
+
/**
|
|
10
|
+
* Vanilla `+onRenderHtml.ts` for no-frontend recipes (api-service, minimal).
|
|
11
|
+
*
|
|
12
|
+
* Vike auto-discovers this file adjacent to `+config.ts` and uses it as the
|
|
13
|
+
* render hook when no vike-* renderer is installed. The page's `Page` export
|
|
14
|
+
* (generated by @rudderjs/vite's scanner from app/Views/Welcome.ts) returns
|
|
15
|
+
* a string body fragment, and this hook wraps it in the document shell.
|
|
16
|
+
*
|
|
17
|
+
* Vike rejects `onRenderHtml` defined inline in `+config.ts` — runtime code
|
|
18
|
+
* (like a render hook) must live in its own file. See
|
|
19
|
+
* https://vike.dev/error/runtime-in-config.
|
|
20
|
+
*/
|
|
21
|
+
export declare function pagesRootRenderHtml(): string;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,wBAAgB,eAAe,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA2C5D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA2B7D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAoC3D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAM3D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA6EhE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA0E9D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CA8EhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAiB5C"}
|
|
@@ -0,0 +1,374 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,6BAA6B;IAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,KA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,IAAI,MAAM,CAoBnC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|