The documentation on Directus 9 extensions is scarce. This is a slightly more detailed implementation than the example given.
router
is an express.Router objectservices
is a bunch of getters of available services (see below)database
is the knex instancedirectus.auth.refresh()
will throw. It's assumed that the user has authenticated in before callingfetchJson
https://github.com/directus/directus/tree/main/api/src/services
services: {
ItemsService: [Getter],
ActivityService: [Getter],
AssetsService: [Getter],
AuthenticationService: [Getter],
CollectionsService: [Getter],
DashboardsService: [Getter],
FieldsService: [Getter],
FilesService: [Getter],
FoldersService: [Getter],
GraphQLGeoJSON: [Getter],
GraphQLDate: [Getter],
GraphQLService: [Getter],
ImportService: [Getter],
MailService: [Getter],
MetaService: [Getter],
NotificationsService: [Getter],
PanelsService: [Getter],
PayloadService: [Getter],
PermissionsService: [Getter],
PresetsService: [Getter],
RelationsService: [Getter],
RevisionsService: [Getter],
RolesService: [Getter],
ServerService: [Getter],
SettingsService: [Getter],
SpecificationService: [Getter],
TFAService: [Getter],
UsersService: [Getter],
UtilsService: [Getter],
WebhooksService: [Getter]
}
https://github.com/directus/directus/blob/main/api/src/services/users.ts
https://github.com/directus/directus/blob/main/api/src/services/items.ts