You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
728 B
37 lines
728 B
import { Directus } from '@directus/sdk';
|
|
|
|
/**
|
|
* Abstract Class for handling Directus Api
|
|
*
|
|
*
|
|
*/
|
|
|
|
class DirectusAbstractStore {
|
|
|
|
/**
|
|
*
|
|
*
|
|
*
|
|
* @param {string} endpoint
|
|
*
|
|
*/
|
|
constructor(endpoint) {
|
|
this.endpoint = endpoint
|
|
|
|
this.directus = new Directus(process.env.DIRECTUS_API_URL, {
|
|
auth: {
|
|
staticToken: process.env.DIRECTUS_API_TOKEN
|
|
}
|
|
})
|
|
|
|
// if endpoint not set throw Error
|
|
if (!this.endpoint) {
|
|
throw new Error('Endpoint in ' + this.constructor.name + ' missing!')
|
|
}
|
|
|
|
// create items
|
|
this.items = this.directus.items(this.endpoint)
|
|
}
|
|
}
|
|
|
|
export default DirectusAbstractStore |