json-crdt-server
Version:
JSON CRDT server and syncing local-first browser client
26 lines (25 loc) • 959 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.del = void 0;
const del = ({ t, services }) => (r) => {
const Request = t.Object(t.prop('id', t.Ref('BlockId')).options({
title: 'Block ID',
description: 'The ID of the block to delete.',
}));
const Response = t.Object(t.prop('success', t.bool).options({
title: 'Success',
description: 'Indicates whether the block was deleted successfully. Returns `false` if the block does not exist.',
}));
const Func = t.Function(Request, Response).options({
title: 'Delete Block',
intro: 'Deletes a block by ID.',
description: 'Deletes a block by ID. It will not rise an error if the block does not exist.',
});
return r.prop('block.del', Func, async ({ id }) => {
const success = await services.blocks.remove(id);
return {
success,
};
});
};
exports.del = del;
;