UNPKG

@n1k1t/mock-server

Version:

The ultimate toolkit to intercept, transform, and simulate HTTP/WS traffic with type-safe expectations

21 lines 744 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../models"); exports.default = models_1.EndpointFactory .build() .http({ method: 'GET', path: '/history' }) .io({ path: 'history:get-by-id' }) .compile(({ reply, incoming, server }) => { const id = incoming.data?.id ?? incoming.query.id; if (!id) { return reply.validationError(['Invalid "id" query parameter']); } for (const provider of server.providers.extract()) { const history = provider.storages.history.get(id); if (history) { return reply.ok(history.toPlain()); } } return reply.notFound(); }); //# sourceMappingURL=history.get-by-id.endpoint.js.map