@nuxt-tmpl/nuxt 0.0.5

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.
Files changed (67) hide show
  1. package/dist/module.d.mts +25 -0
  2. package/dist/module.json +9 -0
  3. package/dist/module.mjs +177 -0
  4. package/dist/runtime/components/auth/AuthGuard.vue +11 -0
  5. package/dist/runtime/components/auth/AuthGuard.vue.d.ts +2 -0
  6. package/dist/runtime/components/auth/AuthSignIn.vue +14 -0
  7. package/dist/runtime/components/auth/AuthSignIn.vue.d.ts +2 -0
  8. package/dist/runtime/components/auth/AuthSignInButton.vue +10 -0
  9. package/dist/runtime/components/auth/AuthSignInButton.vue.d.ts +2 -0
  10. package/dist/runtime/components/auth/AuthSignUp.vue +14 -0
  11. package/dist/runtime/components/auth/AuthSignUp.vue.d.ts +2 -0
  12. package/dist/runtime/components/auth/AuthSignUpButton.vue +10 -0
  13. package/dist/runtime/components/auth/AuthSignUpButton.vue.d.ts +2 -0
  14. package/dist/runtime/components/auth/AuthUserAvatar.vue +20 -0
  15. package/dist/runtime/components/auth/AuthUserAvatar.vue.d.ts +2 -0
  16. package/dist/runtime/components/auth/DefaultSignIn.vue +70 -0
  17. package/dist/runtime/components/auth/DefaultSignIn.vue.d.ts +2 -0
  18. package/dist/runtime/components/auth/DefaultSignUp.vue +81 -0
  19. package/dist/runtime/components/auth/DefaultSignUp.vue.d.ts +2 -0
  20. package/dist/runtime/composables/useAuth.d.ts +2 -0
  21. package/dist/runtime/composables/useAuth.js +5 -0
  22. package/dist/runtime/composables/useAuthForms.d.ts +9 -0
  23. package/dist/runtime/composables/useAuthForms.js +8 -0
  24. package/dist/runtime/layouts/default.vue +79 -0
  25. package/dist/runtime/layouts/default.vue.d.ts +2 -0
  26. package/dist/runtime/middleware/auth.d.ts +2 -0
  27. package/dist/runtime/middleware/auth.js +32 -0
  28. package/dist/runtime/pages/sign-in.vue +18 -0
  29. package/dist/runtime/pages/sign-in.vue.d.ts +2 -0
  30. package/dist/runtime/pages/sign-up.vue +18 -0
  31. package/dist/runtime/pages/sign-up.vue.d.ts +2 -0
  32. package/dist/runtime/plugins/auth.d.ts +6 -0
  33. package/dist/runtime/plugins/auth.js +10 -0
  34. package/dist/runtime/providers/better-auth.d.ts +2 -0
  35. package/dist/runtime/providers/better-auth.js +60 -0
  36. package/dist/runtime/providers/clerk.d.ts +7 -0
  37. package/dist/runtime/providers/clerk.js +112 -0
  38. package/dist/runtime/providers/index.d.ts +2 -0
  39. package/dist/runtime/providers/index.js +48 -0
  40. package/dist/runtime/providers/supabase.d.ts +3 -0
  41. package/dist/runtime/providers/supabase.js +77 -0
  42. package/dist/runtime/server/guards/better-auth.d.ts +9 -0
  43. package/dist/runtime/server/guards/better-auth.js +13 -0
  44. package/dist/runtime/server/guards/clerk.d.ts +3 -0
  45. package/dist/runtime/server/guards/clerk.js +16 -0
  46. package/dist/runtime/server/guards/supabase.d.ts +3 -0
  47. package/dist/runtime/server/guards/supabase.js +12 -0
  48. package/dist/runtime/server/middleware/auth.d.ts +2 -0
  49. package/dist/runtime/server/middleware/auth.js +26 -0
  50. package/dist/runtime/server/middleware/log.d.ts +2 -0
  51. package/dist/runtime/server/middleware/log.js +4 -0
  52. package/dist/runtime/server/plugins/api-response.d.ts +11 -0
  53. package/dist/runtime/server/plugins/api-response.js +32 -0
  54. package/dist/runtime/server/utils/api-response.d.ts +17 -0
  55. package/dist/runtime/server/utils/api-response.js +11 -0
  56. package/dist/runtime/server/utils/auth.d.ts +6 -0
  57. package/dist/runtime/server/utils/auth.js +7 -0
  58. package/dist/runtime/server/utils/handler.d.ts +8 -0
  59. package/dist/runtime/server/utils/handler.js +18 -0
  60. package/dist/runtime/server/utils/llm.d.ts +12 -0
  61. package/dist/runtime/server/utils/llm.js +35 -0
  62. package/dist/runtime/server/utils/supabase.d.ts +2 -0
  63. package/dist/runtime/server/utils/supabase.js +28 -0
  64. package/dist/runtime/utils/authRoute.d.ts +10 -0
  65. package/dist/runtime/utils/authRoute.js +10 -0
  66. package/dist/types.d.mts +9 -0
  67. package/package.json +53 -0
@@ -0,0 +1,28 @@
1
+ import { useRuntimeConfig } from "nitropack/runtime";
2
+ import { createError, parseCookies, setCookie } from "h3";
3
+ import { createServerClient } from "@supabase/ssr";
4
+ export function createServerSupabaseClient(event) {
5
+ const config = useRuntimeConfig();
6
+ const supabaseUrl = config.public.supabase?.url;
7
+ const supabaseAnonKey = config.public.supabase?.anonKey;
8
+ const dbSchema = config.public.supabase?.dbSchema;
9
+ if (!supabaseUrl || !supabaseAnonKey) {
10
+ throw createError({
11
+ statusCode: 500,
12
+ statusMessage: "Supabase URL and anon key must be configured (NUXT_PUBLIC_SUPABASE_URL, NUXT_PUBLIC_SUPABASE_ANON_KEY)"
13
+ });
14
+ }
15
+ return createServerClient(supabaseUrl, supabaseAnonKey, {
16
+ ...dbSchema ? { db: { schema: dbSchema } } : {},
17
+ cookies: {
18
+ getAll() {
19
+ return Object.entries(parseCookies(event)).map(([name, value]) => ({ name, value }));
20
+ },
21
+ setAll(cookiesToSet) {
22
+ cookiesToSet.forEach(({ name, value, options }) => {
23
+ setCookie(event, name, value, options);
24
+ });
25
+ }
26
+ }
27
+ });
28
+ }
@@ -0,0 +1,10 @@
1
+ export type AuthMode = 'guest' | 'public' | 'required';
2
+ interface RouteAuthMeta {
3
+ auth?: AuthMode;
4
+ }
5
+ /**
6
+ * 获取当前页面的鉴权模式
7
+ * 优先使用页面级 meta,其次回退到全局路由配置
8
+ */
9
+ export declare function getAuthMode(path: string, routeMeta: RouteAuthMeta, guestRoutes?: string[], publicRoutes?: string[]): AuthMode;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { isGuestRoute, isSafeRoute } from "@nuxt-tmpl/core";
2
+ export function getAuthMode(path, routeMeta, guestRoutes = [], publicRoutes = []) {
3
+ if (routeMeta.auth)
4
+ return routeMeta.auth;
5
+ if (isGuestRoute(path, guestRoutes))
6
+ return "guest";
7
+ if (isSafeRoute(path, guestRoutes, publicRoutes))
8
+ return "public";
9
+ return "required";
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.mjs'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { default } from './module.mjs'
8
+
9
+ export { type NuxtTmplOptions } from './module.mjs'
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@nuxt-tmpl/nuxt",
3
+ "type": "module",
4
+ "version": "0.0.5",
5
+ "private": false,
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/types.d.mts",
9
+ "development": "./src/module.ts",
10
+ "import": "./dist/module.mjs"
11
+ }
12
+ },
13
+ "publishConfig": {
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/types.d.mts",
17
+ "import": "./dist/module.mjs"
18
+ }
19
+ }
20
+ },
21
+ "main": "./dist/module.mjs",
22
+ "types": "./dist/types.d.mts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "nuxt-module-build build",
28
+ "dev": "nuxt-module-build build --watch",
29
+ "prepublishOnly": "nuxt-module-build build"
30
+ },
31
+ "peerDependencies": {
32
+ "@ai-sdk/openai": "^3.0.0",
33
+ "@clerk/nuxt": "^2.0.0",
34
+ "@supabase/ssr": "^0.10.0",
35
+ "@supabase/supabase-js": "^2.0.0",
36
+ "ai": "^6.0.0",
37
+ "better-auth": "^1.0.0",
38
+ "h3": "^1.0.0",
39
+ "nuxt": "^4.0.0",
40
+ "vue": "^3.0.0"
41
+ },
42
+ "dependencies": {
43
+ "@nuxt/kit": "^4.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@ipa-schema/api": "workspace:*",
47
+ "@ipa-vue/core": "workspace:*",
48
+ "@nuxt-tmpl/core": "workspace:*",
49
+ "@nuxt-tmpl/eslint": "workspace:*",
50
+ "@nuxt/module-builder": "^1.0.0",
51
+ "typescript": "^6.0.0"
52
+ }
53
+ }