Quick start
Generate a resource for the starter kit’s User model. In an existing app, you can use another model with a migrated table.
-
Run your migrations and generate the resource. The generator reads the model and its database table.
Terminal window node ace migration:runnode ace azu:resource User --policy -
Start your dev server.
Terminal window npm run dev -
Sign up at
/signupwith the email you allowed inaccessAdmin. If you already have that account, sign in at/login. -
Open
/adminand choose Users. You can search the list, open a user, and edit their details. Use the app’s signup page to create users. The generated policy omitscreatebecause the required password has no generated admin field.
What the generator writes
Section titled “What the generator writes”For User, azu:resource writes these files:
- The resource in
app/admin/resources/user_resource.ts. - Create and update validators in
app/validators/user_admin.ts. The starter kit already hasapp/validators/user.ts. Pass--no-validatorto skip generating validators. - With
--policy, a policy inapp/policies/user_policy.tsif that file is missing.
Anyone who passes accessAdmin can list, view, and edit users under the generated policy. It denies deletion by omitting delete. Review the resource and restrict the policy to the roles you want before deploying.
Typecheck
Section titled “Typecheck”Run node ace codegen once before you typecheck:
node ace codegennpm run typecheckBouncer’s middleware imports #generated/policies, which codegen writes. So npm run typecheck fails on a fresh app until codegen has run once. The dev server runs it for you.
- Resources explains each part of the file you generated.
- Permissions covers the policy.
- Ace commands lists every flag.