directus-transport-safe-run-middleware
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,4 +0,4 @@ | ||
import { ITransport, TransportRequestOptions, TransportResponse } from '@directus/sdk'; | ||
import { Transport, TransportMethods, TransportOptions, TransportResponse } from '@directus/sdk'; | ||
import { Express } from 'express'; | ||
export default class DirectusTransportSafeRunMiddleware implements ITransport { | ||
export default class DirectusTransportSafeRunMiddleware extends Transport { | ||
protected app: { | ||
@@ -18,10 +18,3 @@ runMiddleware(path: string, payload?: { | ||
constructor(app: Express); | ||
protected readonly request: <T = any, P = any, R = any>(method: string, path: string, options?: TransportRequestOptions, data?: P) => Promise<TransportResponse<T, R>>; | ||
readonly get: <T = any, R = any>(path: string, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly head: <T = any, R = any>(path: string, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly options: <T = any, R = any>(path: string, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly delete: <T = any, P = any, R = any>(path: string, data?: P, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly post: <T = any, P = any, R = any>(path: string, data?: P, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly put: <T = any, P = any, R = any>(path: string, data?: P, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
readonly patch: <T = any, P = any, R = any>(path: string, data?: P, options?: TransportRequestOptions) => Promise<TransportResponse<T, R>>; | ||
protected readonly request: <T = any, R = any>(method: TransportMethods, path: string, data?: Record<string, any>, options?: Omit<TransportOptions, 'url'>) => Promise<TransportResponse<T, R>>; | ||
} |
@@ -15,6 +15,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const sdk_1 = require("@directus/sdk"); | ||
const safe_run_middleware_1 = __importDefault(require("safe-run-middleware")); | ||
class DirectusTransportSafeRunMiddleware { | ||
class DirectusTransportSafeRunMiddleware extends sdk_1.Transport { | ||
constructor(app) { | ||
this.request = (method, path, options, data) => __awaiter(this, void 0, void 0, function* () { | ||
super({ url: '' }); | ||
this.request = (method, path, data, options) => __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
@@ -34,9 +36,2 @@ let response = yield this.app.runMiddleware(path, { | ||
}); | ||
this.get = (path, options) => this.request('get', path, options); | ||
this.head = (path, options) => this.request('head', path, options); | ||
this.options = (path, options) => this.request('options', path, options); | ||
this.delete = (path, data, options) => this.request('delete', path, options, data); | ||
this.post = (path, data, options) => this.request('post', path, options, data); | ||
this.put = (path, data, options) => this.request('put', path, options, data); | ||
this.patch = (path, data, options) => this.request('patch', path, options, data); | ||
this.app = (0, safe_run_middleware_1.default)(app); | ||
@@ -43,0 +38,0 @@ } |
{ | ||
"name": "directus-transport-safe-run-middleware", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A transport for the Directus JavaScript SDK which uses safe-run-middleware", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
5543
57