nuxt-auto-crud 1.22.0 โ 1.22.1
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 +15 -135
- package/dist/module.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nuxt Auto CRUD
|
|
2
2
|
|
|
3
|
-
> **Note:** This module is
|
|
3
|
+
> **Note:** This module is production-ready and actively maintained. The core CRUD API is stable. Minor breaking changes may occasionally occur in advanced features or configuration. We recommend version pinning for production deployments.
|
|
4
4
|
|
|
5
5
|
Auto-expose RESTful CRUD APIs for your **Nuxt** application based solely on your database schema. Minimal configuration required.
|
|
6
6
|
|
|
@@ -56,20 +56,13 @@ If you want to add `nuxt-auto-crud` to an existing project, follow these steps:
|
|
|
56
56
|
#### Install dependencies
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
# Install module and required dependencies
|
|
60
59
|
npm install nuxt-auto-crud @nuxthub/core@^0.10.0 drizzle-orm
|
|
61
|
-
|
|
62
|
-
# Optional: Install auth dependencies if using Session Auth (Recommended)
|
|
63
|
-
npm install nuxt-auth-utils nuxt-authorization
|
|
64
|
-
|
|
60
|
+
npm install nuxt-auth-utils nuxt-authorization # Optional: for authentication
|
|
65
61
|
npm install --save-dev wrangler drizzle-kit
|
|
66
|
-
|
|
67
|
-
# Or using bun
|
|
68
|
-
bun add nuxt-auto-crud @nuxthub/core@latest drizzle-orm
|
|
69
|
-
bun add nuxt-auth-utils nuxt-authorization
|
|
70
|
-
bun add --dev wrangler drizzle-kit
|
|
71
62
|
```
|
|
72
63
|
|
|
64
|
+
> You can also use `bun` or `pnpm` instead of `npm`.
|
|
65
|
+
|
|
73
66
|
#### Configure Nuxt
|
|
74
67
|
|
|
75
68
|
Add the modules to your `nuxt.config.ts`:
|
|
@@ -227,81 +220,18 @@ export default defineConfig({
|
|
|
227
220
|
})
|
|
228
221
|
```
|
|
229
222
|
|
|
230
|
-
## ๐ Authentication
|
|
223
|
+
## ๐ Authentication
|
|
231
224
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
### Session Auth (Default)
|
|
235
|
-
|
|
236
|
-
Requires `nuxt-auth-utils` and `nuxt-authorization` to be installed in your project.
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
npm install nuxt-auth-utils nuxt-authorization
|
|
240
|
-
```
|
|
225
|
+
Authentication is enabled by default using **Session Auth** (requires `nuxt-auth-utils` and `nuxt-authorization`).
|
|
241
226
|
|
|
227
|
+
To disable auth for testing:
|
|
242
228
|
```typescript
|
|
243
|
-
|
|
244
|
-
modules: [
|
|
245
|
-
'nuxt-auth-utils',
|
|
246
|
-
'nuxt-authorization',
|
|
247
|
-
'nuxt-auto-crud'
|
|
248
|
-
],
|
|
249
|
-
autoCrud: {
|
|
250
|
-
auth: {
|
|
251
|
-
type: 'session',
|
|
252
|
-
authentication: true, // Enables requireUserSession() check
|
|
253
|
-
authorization: true // Enables authorize(model, action) check
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
})
|
|
229
|
+
autoCrud: { auth: false }
|
|
257
230
|
```
|
|
258
231
|
|
|
259
|
-
|
|
232
|
+
For **JWT Auth** (backend-only apps) or advanced configuration, see the [Authentication docs](https://auto-crud.clifland.in/docs/configuration/authentication).
|
|
260
233
|
|
|
261
|
-
Useful for backend-only apps. Does **not** require `nuxt-auth-utils`.
|
|
262
234
|
|
|
263
|
-
```typescript
|
|
264
|
-
export default defineNuxtConfig({
|
|
265
|
-
autoCrud: {
|
|
266
|
-
auth: {
|
|
267
|
-
type: 'jwt',
|
|
268
|
-
authentication: true,
|
|
269
|
-
jwtSecret: process.env.JWT_SECRET,
|
|
270
|
-
authorization: true
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Disabling Auth
|
|
277
|
-
|
|
278
|
-
You can disable authentication entirely for testing or public APIs.
|
|
279
|
-
|
|
280
|
-
```typescript
|
|
281
|
-
export default defineNuxtConfig({
|
|
282
|
-
autoCrud: {
|
|
283
|
-
auth: {
|
|
284
|
-
authentication: false,
|
|
285
|
-
authorization: false
|
|
286
|
-
}
|
|
287
|
-
// OR simply:
|
|
288
|
-
// auth: false
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
## ๐งช Testing
|
|
294
|
-
|
|
295
|
-
This module is tested using **Vitest**.
|
|
296
|
-
|
|
297
|
-
- **Unit Tests:** We cover utility functions and helpers.
|
|
298
|
-
- **E2E Tests:** We verify the API endpoints using a real Nuxt server instance.
|
|
299
|
-
|
|
300
|
-
To run the tests locally:
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
npm run test
|
|
304
|
-
```
|
|
305
235
|
|
|
306
236
|
## ๐ก๏ธ Public View Configuration (Field Visibility)
|
|
307
237
|
|
|
@@ -415,51 +345,7 @@ await $fetch("/api/users/1", {
|
|
|
415
345
|
> - **Fullstack App:** The module integrates with `nuxt-auth-utils`, so session cookies are handled automatically.
|
|
416
346
|
> - **Backend-only App:** You must include the `Authorization: Bearer <token>` header in your requests.
|
|
417
347
|
|
|
418
|
-
## Configuration
|
|
419
|
-
|
|
420
|
-
### Module Options
|
|
421
|
-
|
|
422
|
-
```typescript
|
|
423
|
-
|
|
424
|
-
export default defineNuxtConfig({
|
|
425
|
-
autoCrud: {
|
|
426
|
-
// Path to your database schema file (relative to project root)
|
|
427
|
-
schemaPath: "server/db/schema", // default
|
|
428
|
-
|
|
429
|
-
// Authentication configuration (see "Authentication Configuration" section)
|
|
430
|
-
auth: {
|
|
431
|
-
// ...
|
|
432
|
-
},
|
|
433
|
-
|
|
434
|
-
// Public Guest View Configuration (Field Visibility)
|
|
435
|
-
resources: {
|
|
436
|
-
users: ['id', 'name', 'avatar'],
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
});
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
### Protected Fields
|
|
443
348
|
|
|
444
|
-
By default, the following fields are protected from updates:
|
|
445
|
-
|
|
446
|
-
- `id`
|
|
447
|
-
- `createdAt`
|
|
448
|
-
- `created_at`
|
|
449
|
-
- `updatedAt`
|
|
450
|
-
- `updated_at`
|
|
451
|
-
|
|
452
|
-
You can customize updatable fields in your schema by modifying the `modelMapper.ts` utility.
|
|
453
|
-
|
|
454
|
-
### Hidden Fields
|
|
455
|
-
|
|
456
|
-
By default, the following fields are hidden from API responses for security:
|
|
457
|
-
|
|
458
|
-
- `password`
|
|
459
|
-
- `secret`
|
|
460
|
-
- `token`
|
|
461
|
-
|
|
462
|
-
You can customize hidden fields by modifying the `modelMapper.ts` utility.
|
|
463
349
|
|
|
464
350
|
## ๐ง Requirements
|
|
465
351
|
|
|
@@ -467,18 +353,12 @@ You can customize hidden fields by modifying the `modelMapper.ts` utility.
|
|
|
467
353
|
- Drizzle ORM (SQLite)
|
|
468
354
|
- NuxtHub >= 0.10.0
|
|
469
355
|
|
|
470
|
-
## ๐
|
|
471
|
-
|
|
472
|
-
-
|
|
473
|
-
-
|
|
474
|
-
-
|
|
475
|
-
-
|
|
476
|
-
- **YouTube (Add Schemas):** [https://youtu.be/7gW0KW1KtN0](https://youtu.be/7gW0KW1KtN0)
|
|
477
|
-
- **YouTube (Various Permissions):** [https://www.youtube.com/watch?v=Yty3OCYbwOo](https://www.youtube.com/watch?v=Yty3OCYbwOo)
|
|
478
|
-
- **YouTube (Dynamic RBAC):** [https://www.youtube.com/watch?v=W0ju4grRC9M](https://www.youtube.com/watch?v=W0ju4grRC9M)
|
|
479
|
-
- **npm:** [https://www.npmjs.com/package/nuxt-auto-crud](https://www.npmjs.com/package/nuxt-auto-crud)
|
|
480
|
-
- **Github Discussions:** [https://github.com/clifordpereira/nuxt-auto-crud/discussions/1](https://github.com/clifordpereira/nuxt-auto-crud/discussions/1)
|
|
481
|
-
- **Discord:** [https://discord.gg/hGgyEaGu](https://discord.gg/hGgyEaGu)
|
|
356
|
+
## ๐ Links
|
|
357
|
+
|
|
358
|
+
- **๐ Documentation:** [auto-crud.clifland.in](https://auto-crud.clifland.in/docs/auto-crud)
|
|
359
|
+
- **๐ฌ Video Tutorials:** [YouTube Channel](https://www.youtube.com/@ClifordPereira)
|
|
360
|
+
- **๐ฌ Community:** [Discord](https://discord.gg/FBkQQfRFJM) โข [GitHub Discussions](https://github.com/clifordpereira/nuxt-auto-crud/discussions/1)
|
|
361
|
+
- **๐ฆ npm:** [nuxt-auto-crud](https://www.npmjs.com/package/nuxt-auto-crud)
|
|
482
362
|
|
|
483
363
|
## ๐ค Contributing
|
|
484
364
|
|
package/dist/module.json
CHANGED