UNPKG

1.43 kBJavaScriptView Raw
1"use strict";
2/**
3 * @author: JP Lew (jp@cto.ai)
4 * @date: Sunday, 28th April 2019 1:16:46 am
5 * @lastModifiedBy: JP Lew (jp@cto.ai)
6 * @lastModifiedTime: Friday, 7th June 2019 2:56:00 pm
7 * @copyright (c) 2019 CTO.ai
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const tslib_1 = require("tslib");
11const feathers_1 = tslib_1.__importDefault(require("@feathersjs/feathers"));
12const rest_client_1 = tslib_1.__importDefault(require("@feathersjs/rest-client"));
13const axios_1 = tslib_1.__importDefault(require("axios"));
14const url = tslib_1.__importStar(require("url"));
15const env_1 = require("../constants/env");
16exports.localFeathersHost = url.resolve(env_1.OPS_API_HOST, env_1.OPS_API_PATH);
17class FeathersClient {
18 constructor(apiUrl = exports.localFeathersHost) {
19 this.feathersClient = feathers_1.default().configure(rest_client_1.default(apiUrl).axios(axios_1.default));
20 }
21 async find(service, payload) {
22 return this.feathersClient.service(service).find(payload);
23 }
24 async create(service, payload, params) {
25 return this.feathersClient.service(service).create(payload, params);
26 }
27 async patch(service, token, payload) {
28 return this.feathersClient.service(service).patch(token, payload);
29 }
30 async remove(service, id, params) {
31 return this.feathersClient.service(service).remove(id, params);
32 }
33}
34exports.FeathersClient = FeathersClient;