@n1k1t/mock-server
Version:
Powerful util to setup mocks over HTTP APIs
19 lines • 772 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../models");
exports.default = models_1.Endpoint
.build()
.bindToHttp({ method: 'PUT', path: '/expectations' })
.bindToIo({ path: 'expectations:update' })
.assignHandler(async ({ reply, incoming, server }) => {
if (!incoming.data) {
return reply.validationError();
}
const provider = server.providers.extract().find((provider) => provider.storages.expectations.has(incoming.data.id));
if (!provider) {
return reply.notFound();
}
const updated = await provider.client.updateExpectation(incoming.data);
updated ? reply.ok(updated) : reply.notFound();
});
//# sourceMappingURL=expectations.update.endpoint.js.map