A boilerplate for using Directus with best practices inside BCC.
- Clone the repo
- Create
.env
file. You can copy example bycp env.example .env
- Install dependencies by
npm install
- Need to prepare shared to be used by docker
cd shared && npm run build
- Run services by
docker compose up -d
- When you run application for the first time, run
npm run dk-init
.
Initial admin user is: [email protected] | admin
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.
To generate docs/swagger.json
run tsoa spec
.
- Create
exampleService.ts
which extendsItemsService
- Create
exampleController.ts
with injectedexampleService.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.
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.
Command: npm run seed
Look at example under database/seeds/src/index.ts
.
Using knex to seed database.
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.