|
|
||
|---|---|---|
| .github/workflows | ||
| app | ||
| content | ||
| public | ||
| scripts | ||
| server | ||
| shared/utils | ||
| tests | ||
| types | ||
| .editorconfig | ||
| .env.example | ||
| .firebaserc | ||
| .gitignore | ||
| apphosting.yaml | ||
| bun.lock | ||
| content.config.ts | ||
| drizzle.config.ts | ||
| eslint.config.mjs | ||
| firebase.json | ||
| nuxt.config.ts | ||
| package.json | ||
| PERMISSIONS.md | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| renovate.json | ||
| tsconfig.json | ||
| vitest.config.ts | ||
Nuxt Auto CRUD Starter
A starter template for Nuxt Auto CRUD module.
Setup
Make sure to install the dependencies:
pnpm install
Development Server
Start the development server on http://localhost:3000:
pnpm dev
Production
Build the application for production:
pnpm build
Important: When deploying to production, ensure you set the following environment variables:
NUXT_ADMIN_EMAILNUXT_ADMIN_PASSWORDNUXT_SESSION_PASSWORD
Locally preview production build:
pnpm preview
Usage Modes
This template comes pre-configured with nuxt-auto-crud for a fullstack experience.
Fullstack (Default)
No extra steps needed. nuxt-auto-crud is installed and configured.
Frontend Only
If you wish to use this template as a frontend-only application:
- Uninstall the module:
npm uninstall nuxt-auto-crud - Open
nuxt.config.tsand remove'nuxt-auto-crud'from themoduleslist. - Remove the
autoCrudconfiguration block fromnuxt.config.ts.
Permissions & Roles
This template uses a Database-Driven Permissions System.
Unlike previous versions that used JSON configuration files, all roles and permissions are now stored in the database (roles, resources, permissions, role_resource_permissions tables).
How it works:
- Roles: Defined in the
rolestable (e.g.,admin,manager,public). - Resources: Defined in the
resourcestable (e.g.,users,posts). - Permissions: Defined in the
permissionstable (e.g.,create,read,update,delete,list). - Assignment: The
role_resource_permissionstable links them together.
Managing Permissions:
- Seeding: Initial permissions are set up via
server/tasks/seed.ts. You can modify this file to change default permissions. - Runtime: You can build a UI to manage these records directly in the database, allowing for dynamic permission updates without redeploying.
For a detailed guide on managing permissions, see PERMISSIONS.md.
Public Access:
Public (unauthenticated) access is controlled by the public role in the database. Assign permissions to the public role to allow access to resources for non-logged-in users.
Database Reset & Seeding
If you want to delete all data and start fresh:
- Delete the
.datadirectory. - Run the database generation command:
bun db:generate - Run the seed task (this will create default roles, permissions, and users):
npx nuxi task run db:seed (or take tasks in dev tools) - Restart the server:
bun run dev
Default Users:
The seed task creates the following users (Password: $1Password):
- Admin:
admin@example.com(Full Access)- Note: The default password is
$1Password. This hints at the complexity requirements (symbol, number, capital & small letter). You can configure these viaNUXT_ADMIN_EMAILandNUXT_ADMIN_PASSWORDin your.envfile.
- Note: The default password is
- Manager:
manager@example.com - Moderator:
moderator@example.com - Customer:
customer@example.com
Security Note: Log in with the admin credentials, create a new admin user, and then delete the default admin user.