Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 4x 4x 4x 69x 69x 69x 69x 69x 51x 45x 45x | import type {ResolveType} from '@jsonjoy.com/json-type';
import {BlockIdRef, BlockRef} from '../schema';
import type {RouteDeps, Router, RouterBase} from '../../types';
export const get =
({t, services}: RouteDeps) =>
<R extends RouterBase>(r: Router<R>) => {
const Request = t.Object(
t.Key('id', BlockIdRef).options({
title: 'Block ID',
description: 'The ID of the block to retrieve.',
}),
);
const Response = t.Object(t.Key('block', BlockRef));
const Func = t.Function(Request, Response).options({
title: 'Read Block',
intro: 'Retrieves a block by ID.',
});
return r.add('block.get', Func, async ({id}) => {
const {block} = await services.blocks.get(id);
const response: ResolveType<typeof Response> = {block};
return response;
});
};
|