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