create-veap 0.1.3 → 0.3.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.
@@ -1,111 +1,111 @@
1
- import { ApiEnsuredAuth, runApiPipeline } from "@veap/framework/router/server";
2
- import { initializeSystem } from "@/lib/veap";
3
-
4
- export const dynamic = "force-dynamic";
5
-
6
- async function handleRequest(
7
- request: Request,
8
- context: { params: Promise<{ catchAll: string[] }> },
9
- ) {
10
- // Ensure system is initialized (DB injected, plugins registered)
11
- await initializeSystem();
12
-
13
- const { catchAll } = await context.params;
14
- const path = `/api/${catchAll.join("/")}`;
15
-
16
- const { buildRouteTree } = await import("@veap/framework/router/server");
17
- const tree = await buildRouteTree(true);
18
-
19
- const match = tree.match(path);
20
-
21
- const node = match?.node as any;
22
-
23
- if (match?.isExact && node?.route) {
24
- const method = request.method.toUpperCase();
25
- const handler = node.route[method] || node.route.handler;
26
-
27
- if (handler) {
28
- const middlewares = [];
29
-
30
- // Collect middlewares from the layout chain
31
- for (const entry of match.layoutChain) {
32
- if (entry.middlewares) {
33
- middlewares.push(...entry.middlewares);
34
- }
35
- }
36
-
37
- // Node middlewares
38
- if (node.middlewares) {
39
- middlewares.push(...node.middlewares);
40
- }
41
-
42
- // Resolve auth from chain (closest to leaf wins)
43
- let authRequired = node.auth;
44
- if (authRequired === undefined) {
45
- for (let i = match.layoutChain.length - 1; i >= 0; i--) {
46
- if (match.layoutChain[i].auth !== undefined) {
47
- authRequired = match.layoutChain[i].auth;
48
- break;
49
- }
50
- }
51
- }
52
-
53
- // Roles and permissions
54
- let roles = node.roles;
55
- if (!roles) {
56
- for (let i = match.layoutChain.length - 1; i >= 0; i--) {
57
- if (match.layoutChain[i].roles) {
58
- roles = match.layoutChain[i].roles;
59
- break;
60
- }
61
- }
62
- }
63
-
64
- let permissions = node.permissions;
65
- if (!permissions) {
66
- for (let i = match.layoutChain.length - 1; i >= 0; i--) {
67
- if (match.layoutChain[i].permissions) {
68
- permissions = match.layoutChain[i].permissions;
69
- break;
70
- }
71
- }
72
- }
73
-
74
- if (authRequired) {
75
- middlewares.unshift(ApiEnsuredAuth);
76
- }
77
-
78
- return await runApiPipeline(
79
- middlewares as any,
80
- request,
81
- {
82
- params: match.params,
83
- roles,
84
- permissions,
85
- },
86
- async (req: Request, ctx: any) => {
87
- return handler(req, ctx);
88
- },
89
- );
90
- } else {
91
- return new Response(
92
- JSON.stringify({ error: `Method ${method} Not Allowed` }),
93
- {
94
- status: 405,
95
- headers: { "Content-Type": "application/json" },
96
- },
97
- );
98
- }
99
- }
100
-
101
- return new Response(JSON.stringify({ error: "API Route not found" }), {
102
- status: 404,
103
- headers: { "Content-Type": "application/json" },
104
- });
105
- }
106
-
107
- export const GET = handleRequest;
108
- export const POST = handleRequest;
109
- export const PUT = handleRequest;
110
- export const PATCH = handleRequest;
111
- export const DELETE = handleRequest;
1
+ import { ApiEnsuredAuth, runApiPipeline } from "@veap/framework/router/server";
2
+ import { initializeSystem } from "@/lib/veap";
3
+
4
+ export const dynamic = "force-dynamic";
5
+
6
+ async function handleRequest(
7
+ request: Request,
8
+ context: { params: Promise<{ catchAll: string[] }> },
9
+ ) {
10
+ // Ensure system is initialized (DB injected, plugins registered)
11
+ await initializeSystem();
12
+
13
+ const { catchAll } = await context.params;
14
+ const path = `/api/${catchAll.join("/")}`;
15
+
16
+ const { buildRouteTree } = await import("@veap/framework/router/server");
17
+ const tree = await buildRouteTree(true);
18
+
19
+ const match = tree.match(path);
20
+
21
+ const node = match?.node as any;
22
+
23
+ if (match?.isExact && node?.route) {
24
+ const method = request.method.toUpperCase();
25
+ const handler = node.route[method] || node.route.handler;
26
+
27
+ if (handler) {
28
+ const middlewares = [];
29
+
30
+ // Collect middlewares from the layout chain
31
+ for (const entry of match.layoutChain) {
32
+ if (entry.middlewares) {
33
+ middlewares.push(...entry.middlewares);
34
+ }
35
+ }
36
+
37
+ // Node middlewares
38
+ if (node.middlewares) {
39
+ middlewares.push(...node.middlewares);
40
+ }
41
+
42
+ // Resolve auth from chain (closest to leaf wins)
43
+ let authRequired = node.auth;
44
+ if (authRequired === undefined) {
45
+ for (let i = match.layoutChain.length - 1; i >= 0; i--) {
46
+ if (match.layoutChain[i].auth !== undefined) {
47
+ authRequired = match.layoutChain[i].auth;
48
+ break;
49
+ }
50
+ }
51
+ }
52
+
53
+ // Roles and permissions
54
+ let roles = node.roles;
55
+ if (!roles) {
56
+ for (let i = match.layoutChain.length - 1; i >= 0; i--) {
57
+ if (match.layoutChain[i].roles) {
58
+ roles = match.layoutChain[i].roles;
59
+ break;
60
+ }
61
+ }
62
+ }
63
+
64
+ let permissions = node.permissions;
65
+ if (!permissions) {
66
+ for (let i = match.layoutChain.length - 1; i >= 0; i--) {
67
+ if (match.layoutChain[i].permissions) {
68
+ permissions = match.layoutChain[i].permissions;
69
+ break;
70
+ }
71
+ }
72
+ }
73
+
74
+ if (authRequired) {
75
+ middlewares.unshift(ApiEnsuredAuth);
76
+ }
77
+
78
+ return await runApiPipeline(
79
+ middlewares as any,
80
+ request,
81
+ {
82
+ params: match.params,
83
+ roles,
84
+ permissions,
85
+ },
86
+ async (req: Request, ctx: any) => {
87
+ return handler(req, ctx);
88
+ },
89
+ );
90
+ } else {
91
+ return new Response(
92
+ JSON.stringify({ error: `Method ${method} Not Allowed` }),
93
+ {
94
+ status: 405,
95
+ headers: { "Content-Type": "application/json" },
96
+ },
97
+ );
98
+ }
99
+ }
100
+
101
+ return new Response(JSON.stringify({ error: "API Route not found" }), {
102
+ status: 404,
103
+ headers: { "Content-Type": "application/json" },
104
+ });
105
+ }
106
+
107
+ export const GET = handleRequest;
108
+ export const POST = handleRequest;
109
+ export const PUT = handleRequest;
110
+ export const PATCH = handleRequest;
111
+ export const DELETE = handleRequest;
@@ -1,34 +1,34 @@
1
- "use client";
2
-
3
- import { useTranslation } from "@veap/framework/intl";
4
- import { useEffect } from "react";
5
-
6
- export default function ErrorPage({
7
- error,
8
- reset,
9
- }: {
10
- error: Error & { digest?: string };
11
- reset: () => void;
12
- }) {
13
- const { t } = useTranslation();
14
- useEffect(() => {
15
- console.error(error);
16
- }, [error]);
17
-
18
- return (
19
- <div className="flex min-h-screen flex-col items-center justify-center p-4">
20
- <div className="max-w-md text-center">
21
- <h2 className="text-2xl font-bold mb-4">{t("Something went wrong!")}</h2>
22
- <p className="text-muted-foreground mb-6">
23
- {error.message || t("An unexpected error occurred.")}
24
- </p>
25
- <button
26
- onClick={() => reset()}
27
- className="px-4 py-2 bg-primary text-primary-foreground rounded-md hover:opacity-90"
28
- >
29
- {t("Try Again")}
30
- </button>
31
- </div>
32
- </div>
33
- );
34
- }
1
+ "use client";
2
+
3
+ import { useTranslation } from "@veap/framework/intl";
4
+ import { useEffect } from "react";
5
+
6
+ export default function ErrorPage({
7
+ error,
8
+ reset,
9
+ }: {
10
+ error: Error & { digest?: string };
11
+ reset: () => void;
12
+ }) {
13
+ const { t } = useTranslation();
14
+ useEffect(() => {
15
+ console.error(error);
16
+ }, [error]);
17
+
18
+ return (
19
+ <div className="flex min-h-screen flex-col items-center justify-center p-4">
20
+ <div className="max-w-md text-center">
21
+ <h2 className="text-2xl font-bold mb-4">{t("Something went wrong!")}</h2>
22
+ <p className="text-muted-foreground mb-6">
23
+ {error.message || t("An unexpected error occurred.")}
24
+ </p>
25
+ <button
26
+ onClick={() => reset()}
27
+ className="px-4 py-2 bg-primary text-primary-foreground rounded-md hover:opacity-90"
28
+ >
29
+ {t("Try Again")}
30
+ </button>
31
+ </div>
32
+ </div>
33
+ );
34
+ }
@@ -1,124 +1,124 @@
1
- @import "tailwindcss";
2
- @import "tw-animate-css";
3
-
4
- @custom-variant dark (&:is(.dark *));
5
-
6
- @theme inline {
7
- --color-background: var(--background);
8
- --color-foreground: var(--foreground);
9
- --color-card: var(--card);
10
- --color-card-foreground: var(--card-foreground);
11
- --color-popover: var(--popover);
12
- --color-popover-foreground: var(--popover-foreground);
13
- --color-primary: var(--primary);
14
- --color-primary-foreground: var(--primary-foreground);
15
- --color-secondary: var(--secondary);
16
- --color-secondary-foreground: var(--secondary-foreground);
17
- --color-muted: var(--muted);
18
- --color-muted-foreground: var(--muted-foreground);
19
- --color-accent: var(--accent);
20
- --color-accent-foreground: var(--accent-foreground);
21
- --color-destructive: var(--destructive);
22
- --color-destructive-foreground: var(--destructive-foreground);
23
- --color-border: var(--border);
24
- --color-input: var(--input);
25
- --color-ring: var(--ring);
26
- --color-chart-1: var(--chart-1);
27
- --color-chart-2: var(--chart-2);
28
- --color-chart-3: var(--chart-3);
29
- --color-chart-4: var(--chart-4);
30
- --color-chart-5: var(--chart-5);
31
- --radius-sm: calc(var(--radius) * 0.6);
32
- --radius-md: calc(var(--radius) * 0.8);
33
- --radius-lg: var(--radius);
34
- --radius-xl: calc(var(--radius) * 1.4);
35
- --radius-2xl: calc(var(--radius) * 1.8);
36
- --radius-3xl: calc(var(--radius) * 2.2);
37
- --radius-4xl: calc(var(--radius) * 2.6);
38
- --color-sidebar: var(--sidebar);
39
- --color-sidebar-foreground: var(--sidebar-foreground);
40
- --color-sidebar-primary: var(--sidebar-primary);
41
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
42
- --color-sidebar-accent: var(--sidebar-accent);
43
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
44
- --color-sidebar-border: var(--sidebar-border);
45
- --color-sidebar-ring: var(--sidebar-ring);
46
- }
47
-
48
- :root {
49
- --radius: 0.625rem;
50
- --background: oklch(1 0 0);
51
- --foreground: oklch(0.145 0 0);
52
- --card: oklch(1 0 0);
53
- --card-foreground: oklch(0.145 0 0);
54
- --popover: oklch(1 0 0);
55
- --popover-foreground: oklch(0.145 0 0);
56
- --primary: oklch(0.205 0 0);
57
- --primary-foreground: oklch(0.985 0 0);
58
- --secondary: oklch(0.97 0 0);
59
- --secondary-foreground: oklch(0.205 0 0);
60
- --muted: oklch(0.97 0 0);
61
- --muted-foreground: oklch(0.556 0 0);
62
- --accent: oklch(0.97 0 0);
63
- --accent-foreground: oklch(0.205 0 0);
64
- --destructive: oklch(0.577 0.245 27.325);
65
- --border: oklch(0.922 0 0);
66
- --input: oklch(0.922 0 0);
67
- --ring: oklch(0.708 0 0);
68
- --chart-1: oklch(0.646 0.222 41.116);
69
- --chart-2: oklch(0.6 0.118 184.704);
70
- --chart-3: oklch(0.398 0.07 227.392);
71
- --chart-4: oklch(0.828 0.189 84.429);
72
- --chart-5: oklch(0.769 0.188 70.08);
73
- --sidebar: oklch(0.985 0 0);
74
- --sidebar-foreground: oklch(0.145 0 0);
75
- --sidebar-primary: oklch(0.205 0 0);
76
- --sidebar-primary-foreground: oklch(0.985 0 0);
77
- --sidebar-accent: oklch(0.97 0 0);
78
- --sidebar-accent-foreground: oklch(0.205 0 0);
79
- --sidebar-border: oklch(0.922 0 0);
80
- --sidebar-ring: oklch(0.708 0 0);
81
- }
82
-
83
- .dark {
84
- --background: oklch(0.145 0 0);
85
- --foreground: oklch(0.985 0 0);
86
- --card: oklch(0.205 0 0);
87
- --card-foreground: oklch(0.985 0 0);
88
- --popover: oklch(0.205 0 0);
89
- --popover-foreground: oklch(0.985 0 0);
90
- --primary: oklch(0.922 0 0);
91
- --primary-foreground: oklch(0.205 0 0);
92
- --secondary: oklch(0.269 0 0);
93
- --secondary-foreground: oklch(0.985 0 0);
94
- --muted: oklch(0.269 0 0);
95
- --muted-foreground: oklch(0.708 0 0);
96
- --accent: oklch(0.269 0 0);
97
- --accent-foreground: oklch(0.985 0 0);
98
- --destructive: oklch(0.704 0.191 22.216);
99
- --border: oklch(1 0 0 / 10%);
100
- --input: oklch(1 0 0 / 15%);
101
- --ring: oklch(0.556 0 0);
102
- --chart-1: oklch(0.488 0.243 264.376);
103
- --chart-2: oklch(0.696 0.17 162.48);
104
- --chart-3: oklch(0.769 0.188 70.08);
105
- --chart-4: oklch(0.627 0.265 303.9);
106
- --chart-5: oklch(0.645 0.246 16.439);
107
- --sidebar: oklch(0.205 0 0);
108
- --sidebar-foreground: oklch(0.985 0 0);
109
- --sidebar-primary: oklch(0.488 0.243 264.376);
110
- --sidebar-primary-foreground: oklch(0.985 0 0);
111
- --sidebar-accent: oklch(0.269 0 0);
112
- --sidebar-accent-foreground: oklch(0.985 0 0);
113
- --sidebar-border: oklch(1 0 0 / 10%);
114
- --sidebar-ring: oklch(0.556 0 0);
115
- }
116
-
117
- @layer base {
118
- * {
119
- @apply border-border outline-ring/50;
120
- }
121
- body {
122
- @apply bg-background text-foreground;
123
- }
1
+ @import "tailwindcss";
2
+ @import "tw-animate-css";
3
+
4
+ @custom-variant dark (&:is(.dark *));
5
+
6
+ @theme inline {
7
+ --color-background: var(--background);
8
+ --color-foreground: var(--foreground);
9
+ --color-card: var(--card);
10
+ --color-card-foreground: var(--card-foreground);
11
+ --color-popover: var(--popover);
12
+ --color-popover-foreground: var(--popover-foreground);
13
+ --color-primary: var(--primary);
14
+ --color-primary-foreground: var(--primary-foreground);
15
+ --color-secondary: var(--secondary);
16
+ --color-secondary-foreground: var(--secondary-foreground);
17
+ --color-muted: var(--muted);
18
+ --color-muted-foreground: var(--muted-foreground);
19
+ --color-accent: var(--accent);
20
+ --color-accent-foreground: var(--accent-foreground);
21
+ --color-destructive: var(--destructive);
22
+ --color-destructive-foreground: var(--destructive-foreground);
23
+ --color-border: var(--border);
24
+ --color-input: var(--input);
25
+ --color-ring: var(--ring);
26
+ --color-chart-1: var(--chart-1);
27
+ --color-chart-2: var(--chart-2);
28
+ --color-chart-3: var(--chart-3);
29
+ --color-chart-4: var(--chart-4);
30
+ --color-chart-5: var(--chart-5);
31
+ --radius-sm: calc(var(--radius) * 0.6);
32
+ --radius-md: calc(var(--radius) * 0.8);
33
+ --radius-lg: var(--radius);
34
+ --radius-xl: calc(var(--radius) * 1.4);
35
+ --radius-2xl: calc(var(--radius) * 1.8);
36
+ --radius-3xl: calc(var(--radius) * 2.2);
37
+ --radius-4xl: calc(var(--radius) * 2.6);
38
+ --color-sidebar: var(--sidebar);
39
+ --color-sidebar-foreground: var(--sidebar-foreground);
40
+ --color-sidebar-primary: var(--sidebar-primary);
41
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
42
+ --color-sidebar-accent: var(--sidebar-accent);
43
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
44
+ --color-sidebar-border: var(--sidebar-border);
45
+ --color-sidebar-ring: var(--sidebar-ring);
46
+ }
47
+
48
+ :root {
49
+ --radius: 0.625rem;
50
+ --background: oklch(1 0 0);
51
+ --foreground: oklch(0.145 0 0);
52
+ --card: oklch(1 0 0);
53
+ --card-foreground: oklch(0.145 0 0);
54
+ --popover: oklch(1 0 0);
55
+ --popover-foreground: oklch(0.145 0 0);
56
+ --primary: oklch(0.205 0 0);
57
+ --primary-foreground: oklch(0.985 0 0);
58
+ --secondary: oklch(0.97 0 0);
59
+ --secondary-foreground: oklch(0.205 0 0);
60
+ --muted: oklch(0.97 0 0);
61
+ --muted-foreground: oklch(0.556 0 0);
62
+ --accent: oklch(0.97 0 0);
63
+ --accent-foreground: oklch(0.205 0 0);
64
+ --destructive: oklch(0.577 0.245 27.325);
65
+ --border: oklch(0.922 0 0);
66
+ --input: oklch(0.922 0 0);
67
+ --ring: oklch(0.708 0 0);
68
+ --chart-1: oklch(0.646 0.222 41.116);
69
+ --chart-2: oklch(0.6 0.118 184.704);
70
+ --chart-3: oklch(0.398 0.07 227.392);
71
+ --chart-4: oklch(0.828 0.189 84.429);
72
+ --chart-5: oklch(0.769 0.188 70.08);
73
+ --sidebar: oklch(0.985 0 0);
74
+ --sidebar-foreground: oklch(0.145 0 0);
75
+ --sidebar-primary: oklch(0.205 0 0);
76
+ --sidebar-primary-foreground: oklch(0.985 0 0);
77
+ --sidebar-accent: oklch(0.97 0 0);
78
+ --sidebar-accent-foreground: oklch(0.205 0 0);
79
+ --sidebar-border: oklch(0.922 0 0);
80
+ --sidebar-ring: oklch(0.708 0 0);
81
+ }
82
+
83
+ .dark {
84
+ --background: oklch(0.145 0 0);
85
+ --foreground: oklch(0.985 0 0);
86
+ --card: oklch(0.205 0 0);
87
+ --card-foreground: oklch(0.985 0 0);
88
+ --popover: oklch(0.205 0 0);
89
+ --popover-foreground: oklch(0.985 0 0);
90
+ --primary: oklch(0.922 0 0);
91
+ --primary-foreground: oklch(0.205 0 0);
92
+ --secondary: oklch(0.269 0 0);
93
+ --secondary-foreground: oklch(0.985 0 0);
94
+ --muted: oklch(0.269 0 0);
95
+ --muted-foreground: oklch(0.708 0 0);
96
+ --accent: oklch(0.269 0 0);
97
+ --accent-foreground: oklch(0.985 0 0);
98
+ --destructive: oklch(0.704 0.191 22.216);
99
+ --border: oklch(1 0 0 / 10%);
100
+ --input: oklch(1 0 0 / 15%);
101
+ --ring: oklch(0.556 0 0);
102
+ --chart-1: oklch(0.488 0.243 264.376);
103
+ --chart-2: oklch(0.696 0.17 162.48);
104
+ --chart-3: oklch(0.769 0.188 70.08);
105
+ --chart-4: oklch(0.627 0.265 303.9);
106
+ --chart-5: oklch(0.645 0.246 16.439);
107
+ --sidebar: oklch(0.205 0 0);
108
+ --sidebar-foreground: oklch(0.985 0 0);
109
+ --sidebar-primary: oklch(0.488 0.243 264.376);
110
+ --sidebar-primary-foreground: oklch(0.985 0 0);
111
+ --sidebar-accent: oklch(0.269 0 0);
112
+ --sidebar-accent-foreground: oklch(0.985 0 0);
113
+ --sidebar-border: oklch(1 0 0 / 10%);
114
+ --sidebar-ring: oklch(0.556 0 0);
115
+ }
116
+
117
+ @layer base {
118
+ * {
119
+ @apply border-border outline-ring/50;
120
+ }
121
+ body {
122
+ @apply bg-background text-foreground;
123
+ }
124
124
  }