json-crdt-server
Version:
JSON CRDT server and syncing local-first browser client
22 lines (21 loc) • 755 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.get = void 0;
const schema_1 = require("../schema");
const get = ({ t, services }) => (r) => {
const Request = t.Object(t.prop('id', schema_1.BlockIdRef).options({
title: 'Block ID',
description: 'The ID of the block to retrieve.',
}));
const Response = t.Object(t.prop('block', schema_1.BlockRef));
const Func = t.Function(Request, Response).options({
title: 'Read Block',
intro: 'Retrieves a block by ID.',
});
return r.prop('block.get', Func, async ({ id }) => {
const { block } = await services.blocks.get(id);
const response = { block };
return response;
});
};
exports.get = get;
;