Skip to content

A boilerplate for using Directus with best practices inside BCC

License

Notifications You must be signed in to change notification settings

bcc-code/bcc-directus-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Directus app boilerplate

A boilerplate for using Directus with best practices inside BCC.

Setup locally (useing docker)

  1. Clone the repo
  2. Create .env file. You can copy example by cp env.example .env
  3. Install dependencies by npm install
  4. Need to prepare shared to be used by docker cd shared && npm run build
  5. Run services by docker compose up -d
  6. When you run application for the first time, run npm run dk-init.

Initial admin user is: admin@example.com | admin

Documentation

Auto swagger documentation for custom endpoints

The swagger documentation generated by directus does not contain custom endpoints. In the project, we use the tsoa library to generate swagger documentation for our public api.

Usage

To generate docs/swagger.json run tsoa spec.

Convention

  • Create exampleService.ts which extends ItemsService
  • Create exampleController.ts with injected exampleService.ts. Controller should contains tsoa annotations
  • Create index.ts file to register custom directus endpoints. There you can add endpoint, create controller instance and execute the desired method.

Important

There is a problem with @Query annotation when query is an object. In that case just use @Inject, but your query will not be in the documentation.

Seeding data to database

Command: npm run seed

Look at example under database/seeds/src/index.ts.

Using knex to seed database.

RBAC sync

In the .env file, set the RBAC synchronization mode before database initialization to: RBAC_SYNC_MODE=EXPORT

If the database is already initialized, you can set it to: RBAC_SYNC_MODE=FULL

Otherwise, you may run into problems initializing the app.

About

A boilerplate for using Directus with best practices inside BCC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published