vasp-cli 0.4.0 → 0.9.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/dist/vasp +82 -34
- package/package.json +2 -2
- package/starters/minimal.vasp +1 -1
- package/starters/recipe.vasp +11 -20
- package/starters/todo-auth-ssr.vasp +33 -20
- package/starters/todo.vasp +15 -8
- package/templates/shared/.gitignore.hbs +1 -0
- package/templates/shared/auth/server/index.hbs +4 -8
- package/templates/shared/auth/server/middleware.hbs +33 -15
- package/templates/{templates/shared → shared}/auth/server/plugin.hbs +0 -2
- package/templates/shared/auth/server/providers/github.hbs +1 -1
- package/templates/shared/auth/server/providers/google.hbs +1 -1
- package/templates/shared/auth/server/providers/usernameAndPassword.hbs +3 -6
- package/templates/shared/bunfig.toml.hbs +3 -0
- package/templates/shared/drizzle/schema.hbs +38 -19
- package/templates/shared/package.json.hbs +11 -4
- package/templates/shared/server/db/client.hbs +19 -1
- package/templates/shared/server/db/seed.hbs +16 -0
- package/templates/shared/server/index.hbs +40 -0
- package/templates/shared/server/middleware/errorHandler.hbs +75 -0
- package/templates/shared/server/middleware/logger.hbs +74 -0
- package/templates/shared/server/middleware/rateLimit.hbs +2 -2
- package/templates/shared/server/routes/_vasp.hbs +37 -0
- package/templates/shared/server/routes/actions/_action.hbs +5 -1
- package/templates/shared/server/routes/api/_api.hbs +24 -0
- package/templates/shared/server/routes/crud/_crud.hbs +58 -10
- package/templates/shared/server/routes/queries/_query.hbs +5 -1
- package/templates/shared/shared/types.hbs +58 -0
- package/templates/shared/shared/validation.hbs +20 -0
- package/templates/shared/tests/actions/_action.test.js.hbs +7 -0
- package/templates/shared/tests/actions/_action.test.ts.hbs +7 -0
- package/templates/shared/tests/auth/login.test.js.hbs +7 -0
- package/templates/shared/tests/auth/login.test.ts.hbs +7 -0
- package/templates/shared/tests/crud/_entity.test.js.hbs +7 -0
- package/templates/shared/tests/crud/_entity.test.ts.hbs +7 -0
- package/templates/shared/tests/queries/_query.test.js.hbs +7 -0
- package/templates/shared/tests/queries/_query.test.ts.hbs +7 -0
- package/templates/shared/tests/setup.js.hbs +5 -0
- package/templates/shared/tests/setup.ts.hbs +5 -0
- package/templates/shared/tests/vitest.config.js.hbs +8 -0
- package/templates/shared/tests/vitest.config.ts.hbs +8 -0
- package/templates/shared/tsconfig.json.hbs +2 -1
- package/templates/spa/js/src/App.vue.hbs +9 -1
- package/templates/spa/js/src/components/VaspErrorBoundary.vue.hbs +33 -0
- package/templates/spa/js/src/components/VaspNotifications.vue.hbs +60 -0
- package/templates/spa/js/src/vasp/auth.js.hbs +31 -15
- package/templates/spa/js/src/vasp/client/actions.js.hbs +7 -1
- package/templates/spa/js/src/vasp/client/crud.js.hbs +94 -5
- package/templates/spa/js/src/vasp/useVaspNotifications.js.hbs +35 -0
- package/templates/spa/js/vite.config.js.hbs +1 -0
- package/templates/spa/ts/src/App.vue.hbs +9 -1
- package/templates/spa/ts/src/components/VaspErrorBoundary.vue.hbs +33 -0
- package/templates/spa/ts/src/components/VaspNotifications.vue.hbs +60 -0
- package/templates/spa/ts/src/vasp/auth.ts.hbs +31 -15
- package/templates/spa/ts/src/vasp/client/actions.ts.hbs +7 -1
- package/templates/spa/ts/src/vasp/client/crud.ts.hbs +96 -10
- package/templates/spa/ts/src/vasp/client/types.ts.hbs +14 -28
- package/templates/spa/ts/src/vasp/useVaspNotifications.ts.hbs +41 -0
- package/templates/spa/ts/vite.config.ts.hbs +1 -0
- package/templates/ssr/js/error.vue.hbs +23 -0
- package/templates/ssr/js/nuxt.config.js.hbs +1 -0
- package/templates/ssr/ts/error.vue.hbs +26 -0
- package/templates/ssr/ts/nuxt.config.ts.hbs +1 -0
- package/templates/starters/minimal.vasp +15 -0
- package/templates/starters/recipe.vasp +70 -0
- package/templates/starters/todo-auth-ssr.vasp +65 -0
- package/templates/starters/todo.vasp +42 -0
- package/templates/templates/shared/.env.example.hbs +0 -14
- package/templates/templates/shared/.gitignore.hbs +0 -8
- package/templates/templates/shared/auth/client/Login.vue.hbs +0 -46
- package/templates/templates/shared/auth/client/Register.vue.hbs +0 -42
- package/templates/templates/shared/auth/server/index.hbs +0 -46
- package/templates/templates/shared/auth/server/middleware.hbs +0 -33
- package/templates/templates/shared/auth/server/providers/github.hbs +0 -48
- package/templates/templates/shared/auth/server/providers/google.hbs +0 -53
- package/templates/templates/shared/auth/server/providers/usernameAndPassword.hbs +0 -66
- package/templates/templates/shared/bunfig.toml.hbs +0 -5
- package/templates/templates/shared/drizzle/drizzle.config.hbs +0 -10
- package/templates/templates/shared/drizzle/schema.hbs +0 -48
- package/templates/templates/shared/jobs/_job.hbs +0 -34
- package/templates/templates/shared/jobs/boss.hbs +0 -15
- package/templates/templates/shared/package.json.hbs +0 -38
- package/templates/templates/shared/server/db/client.hbs +0 -12
- package/templates/templates/shared/server/index.hbs +0 -73
- package/templates/templates/shared/server/middleware/csrf.hbs +0 -34
- package/templates/templates/shared/server/middleware/rateLimit.hbs +0 -44
- package/templates/templates/shared/server/routes/actions/_action.hbs +0 -20
- package/templates/templates/shared/server/routes/crud/_crud.hbs +0 -86
- package/templates/templates/shared/server/routes/jobs/_schedule.hbs +0 -12
- package/templates/templates/shared/server/routes/queries/_query.hbs +0 -20
- package/templates/templates/shared/server/routes/realtime/_channel.hbs +0 -78
- package/templates/templates/shared/server/routes/realtime/index.hbs +0 -9
- package/templates/templates/shared/tsconfig.json.hbs +0 -21
- package/templates/templates/spa/js/index.html.hbs +0 -12
- package/templates/templates/spa/js/src/App.vue.hbs +0 -3
- package/templates/templates/spa/js/src/main.js.hbs +0 -9
- package/templates/templates/spa/js/src/router/index.js.hbs +0 -41
- package/templates/templates/spa/js/src/vasp/auth.js.hbs +0 -45
- package/templates/templates/spa/js/src/vasp/client/actions.js.hbs +0 -15
- package/templates/templates/spa/js/src/vasp/client/crud.js.hbs +0 -30
- package/templates/templates/spa/js/src/vasp/client/index.js.hbs +0 -16
- package/templates/templates/spa/js/src/vasp/client/queries.js.hbs +0 -15
- package/templates/templates/spa/js/src/vasp/client/realtime.js.hbs +0 -51
- package/templates/templates/spa/js/src/vasp/plugin.js.hbs +0 -11
- package/templates/templates/spa/js/vite.config.js.hbs +0 -26
- package/templates/templates/spa/ts/index.html.hbs +0 -12
- package/templates/templates/spa/ts/src/App.vue.hbs +0 -3
- package/templates/templates/spa/ts/src/main.ts.hbs +0 -9
- package/templates/templates/spa/ts/src/router/index.ts.hbs +0 -41
- package/templates/templates/spa/ts/src/vasp/auth.ts.hbs +0 -53
- package/templates/templates/spa/ts/src/vasp/client/actions.ts.hbs +0 -19
- package/templates/templates/spa/ts/src/vasp/client/crud.ts.hbs +0 -37
- package/templates/templates/spa/ts/src/vasp/client/index.ts.hbs +0 -17
- package/templates/templates/spa/ts/src/vasp/client/queries.ts.hbs +0 -19
- package/templates/templates/spa/ts/src/vasp/client/realtime.ts.hbs +0 -56
- package/templates/templates/spa/ts/src/vasp/client/types.ts.hbs +0 -33
- package/templates/templates/spa/ts/src/vasp/plugin.ts.hbs +0 -12
- package/templates/templates/spa/ts/vite.config.ts.hbs +0 -26
- package/templates/templates/ssr/js/_page.vue.hbs +0 -10
- package/templates/templates/ssr/js/app.vue.hbs +0 -3
- package/templates/templates/ssr/js/composables/useAuth.js.hbs +0 -52
- package/templates/templates/ssr/js/composables/useVasp.js.hbs +0 -6
- package/templates/templates/ssr/js/middleware/auth.js.hbs +0 -8
- package/templates/templates/ssr/js/nuxt.config.js.hbs +0 -15
- package/templates/templates/ssr/js/plugins/vasp.client.js.hbs +0 -27
- package/templates/templates/ssr/js/plugins/vasp.server.js.hbs +0 -33
- package/templates/templates/ssr/ts/_page.vue.hbs +0 -10
- package/templates/templates/ssr/ts/app.vue.hbs +0 -3
- package/templates/templates/ssr/ts/composables/useAuth.ts.hbs +0 -56
- package/templates/templates/ssr/ts/composables/useVasp.ts.hbs +0 -10
- package/templates/templates/ssr/ts/middleware/auth.ts.hbs +0 -8
- package/templates/templates/ssr/ts/nuxt.config.ts.hbs +0 -19
- package/templates/templates/ssr/ts/plugins/vasp.client.ts.hbs +0 -27
- package/templates/templates/ssr/ts/plugins/vasp.server.ts.hbs +0 -33
- /package/templates/{templates/shared → shared}/.env.hbs +0 -0
- /package/templates/{templates/shared → shared}/README.md.hbs +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// Runs only on the client after hydration — routes calls to the Elysia backend via ofetch
|
|
3
|
-
import { $fetch } from 'ofetch'
|
|
4
|
-
|
|
5
|
-
function getCsrfToken() {
|
|
6
|
-
const match = document.cookie.match(/(?:^|;\s*)vasp-csrf=([^;]*)/)
|
|
7
|
-
return match ? decodeURIComponent(match[1]) : undefined
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
11
|
-
const config = useRuntimeConfig()
|
|
12
|
-
const baseURL = config.public.apiBase
|
|
13
|
-
|
|
14
|
-
nuxtApp.provide('vasp', {
|
|
15
|
-
async query(name, args) {
|
|
16
|
-
return $fetch(`/queries/${name}`, { baseURL, method: 'GET', query: args })
|
|
17
|
-
},
|
|
18
|
-
async action(name, args) {
|
|
19
|
-
return $fetch(`/actions/${name}`, {
|
|
20
|
-
baseURL,
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: args,
|
|
23
|
-
headers: { 'x-csrf-token': getCsrfToken() ?? '' },
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
})
|
|
27
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// Runs only on the server during SSR render — calls query/action functions directly (zero HTTP overhead)
|
|
3
|
-
{{#each queries}}
|
|
4
|
-
import { {{importName fn}} } from '{{fn.source}}'
|
|
5
|
-
{{/each}}
|
|
6
|
-
{{#each actions}}
|
|
7
|
-
import { {{importName fn}} } from '{{fn.source}}'
|
|
8
|
-
{{/each}}
|
|
9
|
-
|
|
10
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
11
|
-
const queryFns = {
|
|
12
|
-
{{#each queries}}
|
|
13
|
-
{{camelCase name}}: {{importName fn}},
|
|
14
|
-
{{/each}}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const actionFns = {
|
|
18
|
-
{{#each actions}}
|
|
19
|
-
{{camelCase name}}: {{importName fn}},
|
|
20
|
-
{{/each}}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
nuxtApp.provide('vasp', {
|
|
24
|
-
async query(name, args) {
|
|
25
|
-
if (!queryFns[name]) throw new Error(`[Vasp] Unknown query: ${name}`)
|
|
26
|
-
return queryFns[name](args)
|
|
27
|
-
},
|
|
28
|
-
async action(name, args) {
|
|
29
|
-
if (!actionFns[name]) throw new Error(`[Vasp] Unknown action: ${name}`)
|
|
30
|
-
return actionFns[name](args)
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
})
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// SSR-aware auth composable — uses cookies (httpOnly) and Nuxt's useRequestHeaders for server-side access
|
|
3
|
-
import { $fetch } from 'ofetch'
|
|
4
|
-
|
|
5
|
-
interface AuthUser {
|
|
6
|
-
id: number
|
|
7
|
-
username: string
|
|
8
|
-
email?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const _user = ref<AuthUser | null>(null)
|
|
12
|
-
let _checked = false
|
|
13
|
-
|
|
14
|
-
export function useAuth() {
|
|
15
|
-
const config = useRuntimeConfig()
|
|
16
|
-
const baseURL = config.public.apiBase as string
|
|
17
|
-
const headers = import.meta.server ? useRequestHeaders(['cookie']) : {}
|
|
18
|
-
|
|
19
|
-
async function checkAuth(): Promise<void> {
|
|
20
|
-
if (_checked) return
|
|
21
|
-
_checked = true
|
|
22
|
-
try {
|
|
23
|
-
_user.value = await $fetch<AuthUser>(`${baseURL}/auth/me`, { headers, credentials: 'include' })
|
|
24
|
-
} catch {
|
|
25
|
-
_user.value = null
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function login(username: string, password: string): Promise<AuthUser> {
|
|
30
|
-
_user.value = await $fetch<AuthUser>(`${baseURL}/auth/login`, {
|
|
31
|
-
method: 'POST',
|
|
32
|
-
body: { username, password },
|
|
33
|
-
credentials: 'include',
|
|
34
|
-
})
|
|
35
|
-
_checked = true
|
|
36
|
-
return _user.value!
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function register(username: string, password: string, email?: string): Promise<AuthUser> {
|
|
40
|
-
_user.value = await $fetch<AuthUser>(`${baseURL}/auth/register`, {
|
|
41
|
-
method: 'POST',
|
|
42
|
-
body: { username, password, email },
|
|
43
|
-
credentials: 'include',
|
|
44
|
-
})
|
|
45
|
-
_checked = true
|
|
46
|
-
return _user.value!
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function logout(): Promise<void> {
|
|
50
|
-
await $fetch(`${baseURL}/auth/logout`, { method: 'POST', credentials: 'include' })
|
|
51
|
-
_user.value = null
|
|
52
|
-
_checked = false
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return { user: _user, checkAuth, login, register, logout }
|
|
56
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
interface VaspClient {
|
|
3
|
-
query<T = unknown>(name: string, args?: unknown): Promise<T>
|
|
4
|
-
action<T = unknown>(name: string, args?: unknown): Promise<T>
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const useVasp = (): { $vasp: VaspClient } => {
|
|
8
|
-
const { $vasp } = useNuxtApp()
|
|
9
|
-
return { $vasp: $vasp as VaspClient }
|
|
10
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
export default defineNuxtRouteMiddleware((to) => {
|
|
3
|
-
const { user } = useAuth()
|
|
4
|
-
const publicPaths = ['/login', '/register']
|
|
5
|
-
if (!user.value && !publicPaths.includes(to.path)) {
|
|
6
|
-
return navigateTo('/login')
|
|
7
|
-
}
|
|
8
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
3
|
-
export default defineNuxtConfig({
|
|
4
|
-
compatibilityDate: '2024-11-01',
|
|
5
|
-
devtools: { enabled: true },
|
|
6
|
-
typescript: {
|
|
7
|
-
strict: true,
|
|
8
|
-
typeCheck: true,
|
|
9
|
-
},
|
|
10
|
-
alias: {
|
|
11
|
-
'@src': '~/src',
|
|
12
|
-
},
|
|
13
|
-
runtimeConfig: {
|
|
14
|
-
backendUrl: process.env.BACKEND_URL || 'http://localhost:{{backendPort}}',
|
|
15
|
-
public: {
|
|
16
|
-
apiBase: process.env.API_BASE || 'http://localhost:{{backendPort}}/api',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// Runs only on the client after hydration — routes calls to the Elysia backend via ofetch
|
|
3
|
-
import { $fetch } from 'ofetch'
|
|
4
|
-
|
|
5
|
-
function getCsrfToken(): string | undefined {
|
|
6
|
-
const match = document.cookie.match(/(?:^|;\s*)vasp-csrf=([^;]*)/)
|
|
7
|
-
return match ? decodeURIComponent(match[1]) : undefined
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
11
|
-
const config = useRuntimeConfig()
|
|
12
|
-
const baseURL = config.public.apiBase as string
|
|
13
|
-
|
|
14
|
-
nuxtApp.provide('vasp', {
|
|
15
|
-
async query<T = unknown>(name: string, args?: unknown): Promise<T> {
|
|
16
|
-
return $fetch<T>(`/queries/${name}`, { baseURL, method: 'GET', query: args as Record<string, unknown> })
|
|
17
|
-
},
|
|
18
|
-
async action<T = unknown>(name: string, args?: unknown): Promise<T> {
|
|
19
|
-
return $fetch<T>(`/actions/${name}`, {
|
|
20
|
-
baseURL,
|
|
21
|
-
method: 'POST',
|
|
22
|
-
body: args,
|
|
23
|
-
headers: { 'x-csrf-token': getCsrfToken() ?? '' },
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
})
|
|
27
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Auto-generated by Vasp — do not edit directly
|
|
2
|
-
// Runs only on the server during SSR render — calls query/action functions directly (zero HTTP overhead)
|
|
3
|
-
{{#each queries}}
|
|
4
|
-
import { {{importName fn}} } from '{{fn.source}}'
|
|
5
|
-
{{/each}}
|
|
6
|
-
{{#each actions}}
|
|
7
|
-
import { {{importName fn}} } from '{{fn.source}}'
|
|
8
|
-
{{/each}}
|
|
9
|
-
|
|
10
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
11
|
-
const queryFns: Record<string, (args?: unknown) => Promise<unknown>> = {
|
|
12
|
-
{{#each queries}}
|
|
13
|
-
{{camelCase name}}: {{importName fn}} as (args?: unknown) => Promise<unknown>,
|
|
14
|
-
{{/each}}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const actionFns: Record<string, (args?: unknown) => Promise<unknown>> = {
|
|
18
|
-
{{#each actions}}
|
|
19
|
-
{{camelCase name}}: {{importName fn}} as (args?: unknown) => Promise<unknown>,
|
|
20
|
-
{{/each}}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
nuxtApp.provide('vasp', {
|
|
24
|
-
async query<T = unknown>(name: string, args?: unknown): Promise<T> {
|
|
25
|
-
if (!queryFns[name]) throw new Error(`[Vasp] Unknown query: ${name}`)
|
|
26
|
-
return queryFns[name](args) as Promise<T>
|
|
27
|
-
},
|
|
28
|
-
async action<T = unknown>(name: string, args?: unknown): Promise<T> {
|
|
29
|
-
if (!actionFns[name]) throw new Error(`[Vasp] Unknown action: ${name}`)
|
|
30
|
-
return actionFns[name](args) as Promise<T>
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
})
|
|
File without changes
|
|
File without changes
|