vasp-cli 0.3.1 → 0.4.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 +25 -24
- package/package.json +1 -1
- package/starters/recipe.vasp +79 -0
- package/templates/shared/auth/client/Login.vue.hbs +1 -1
- package/templates/shared/auth/client/Register.vue.hbs +1 -1
- package/templates/shared/drizzle/drizzle.config.hbs +10 -0
- package/templates/shared/drizzle/schema.hbs +14 -3
- package/templates/shared/jobs/_job.hbs +12 -2
- package/templates/shared/package.json.hbs +4 -1
- package/templates/shared/server/index.hbs +8 -0
- package/templates/shared/server/middleware/csrf.hbs +34 -0
- package/templates/shared/server/middleware/rateLimit.hbs +44 -0
- package/templates/shared/server/routes/crud/_crud.hbs +47 -3
- package/templates/shared/server/routes/realtime/_channel.hbs +58 -10
- package/templates/ssr/js/plugins/vasp.client.js.hbs +11 -1
- package/templates/ssr/ts/plugins/vasp.client.ts.hbs +11 -1
- package/templates/templates/shared/.env.hbs +14 -0
- package/templates/templates/shared/README.md.hbs +53 -0
- package/templates/templates/shared/auth/server/index.hbs +3 -8
- package/templates/templates/shared/auth/server/plugin.hbs +9 -0
- package/templates/templates/shared/auth/server/providers/github.hbs +1 -1
- package/templates/templates/shared/auth/server/providers/google.hbs +1 -1
- package/templates/templates/shared/auth/server/providers/usernameAndPassword.hbs +3 -6
- package/templates/templates/shared/bunfig.toml.hbs +3 -0
- package/templates/templates/shared/package.json.hbs +4 -1
- package/templates/templates/shared/server/index.hbs +13 -0
|
@@ -2,17 +2,14 @@ import { Elysia, t } from 'elysia'
|
|
|
2
2
|
import { db } from '../../db/client.{{ext}}'
|
|
3
3
|
import { users } from '../../../drizzle/schema.{{ext}}'
|
|
4
4
|
import { eq } from 'drizzle-orm'
|
|
5
|
-
import { authPlugin } from '../
|
|
5
|
+
import { authPlugin } from '../plugin.{{ext}}'
|
|
6
6
|
|
|
7
7
|
async function hashPassword(password{{#if isTypeScript}}: string{{/if}}) {
|
|
8
|
-
|
|
9
|
-
const data = encoder.encode(password)
|
|
10
|
-
const hash = await crypto.subtle.digest('SHA-256', data)
|
|
11
|
-
return Buffer.from(hash).toString('hex')
|
|
8
|
+
return Bun.password.hash(password, 'argon2id')
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
async function verifyPassword(password{{#if isTypeScript}}: string{{/if}}, hash{{#if isTypeScript}}: string{{/if}}) {
|
|
15
|
-
return (
|
|
12
|
+
return Bun.password.verify(password, hash)
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
export const usernameAndPasswordRoutes = new Elysia()
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
"dev:client": "{{#if isSpa}}vite{{else}}nuxt dev{{/if}}",
|
|
11
11
|
"db:generate": "bunx drizzle-kit generate",
|
|
12
12
|
"db:migrate": "bunx drizzle-kit migrate",
|
|
13
|
+
"db:push": "bunx drizzle-kit push",
|
|
13
14
|
"db:studio": "bunx drizzle-kit studio"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@vasp-framework/runtime": "^0.1.0",
|
|
17
18
|
"elysia": "^1.1.0",
|
|
18
19
|
"@elysiajs/cors": "^1.1.0",
|
|
19
|
-
"@elysiajs/static": "^1.1.0",
|
|
20
|
+
"@elysiajs/static": "^1.1.0",{{#if auth}}
|
|
21
|
+
"@elysiajs/jwt": "^1.1.0",
|
|
22
|
+
"@elysiajs/cookie": "^0.8.0",{{/if}}
|
|
20
23
|
"drizzle-orm": "^0.36.0",
|
|
21
24
|
"postgres": "^3.4.0",
|
|
22
25
|
"ofetch": "^1.3.4",
|
|
@@ -55,6 +55,19 @@ const app = new Elysia()
|
|
|
55
55
|
{{#each jobs}}
|
|
56
56
|
.use({{camelCase name}}ScheduleRoute)
|
|
57
57
|
{{/each}}
|
|
58
|
+
.onError(({ code, error, set }) => {
|
|
59
|
+
if (code === 'NOT_FOUND') {
|
|
60
|
+
set.status = 404
|
|
61
|
+
return { error: 'Not found' }
|
|
62
|
+
}
|
|
63
|
+
if (code === 'VALIDATION') {
|
|
64
|
+
set.status = 400
|
|
65
|
+
return { error: 'Validation failed', details: error.message }
|
|
66
|
+
}
|
|
67
|
+
console.error('[server error]', error)
|
|
68
|
+
set.status = 500
|
|
69
|
+
return { error: 'Internal server error' }
|
|
70
|
+
})
|
|
58
71
|
.listen(PORT)
|
|
59
72
|
|
|
60
73
|
console.log(`🚀 Vasp backend running at http://localhost:${PORT}`)
|