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.
ass/src/data.ts

26 lines
611 B

/**
* Used for global data management
*/
import fs from 'fs-extra';
import { Config } from 'ass-json';
import { JsonDataEngine } from '@tycrek/papito'
let theData: any;
/**
* Called by ass.ts on startup
* @since v0.14.2
*/
export const onStart = () => new Promise((resolve, reject) => {
// Actual data engine
const { dataEngine }: Config = fs.readJsonSync('config.json');
import(dataEngine)
.then(({ _ENGINE_ }) => theData = _ENGINE_(new JsonDataEngine()))
.then(resolve)
.catch(reject);
});
// Export a self-calling const function returning the data
export const data = ((): any => theData);