UNPKG

@jsstudio/development-api-interceptor

Version:
33 lines 1.23 kB
import { INDEXED_DB_ERROR } from './constants'; import indexedDb from './indexed-db'; import { Interceptor } from './interceptors'; import { logger } from './utils/logger'; import { Validation } from './validation'; class MockApi { constructor(jsonSchema) { /** * This function is the entry point to validate and pass the json for indexedDB . * * @param {any} jsonData - Json object received from frontend . * @param {AxiosStatic} axios Instance of axios . * @returns { boolean} isValid . */ this.initialize = () => { const tables = this.jsonSchema.tables.map((item) => item.table_name); const validate = new Validation(); const interceptor = new Interceptor(tables); try { validate.jsonSchema(this.jsonSchema); indexedDb.setDatabase(this.jsonSchema.database); indexedDb.initialize(this.jsonSchema); interceptor.initialize(); } catch (err) { logger(INDEXED_DB_ERROR, err); } }; this.jsonSchema = jsonSchema; } } export default MockApi; //# sourceMappingURL=index.js.map