From 535d10f4694f532a5ce85f536bed2adb9804e7d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 25 Apr 2019 14:40:42 +0900 Subject: Improve API console --- src/server/api/endpoints/endpoint.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/server/api/endpoints/endpoint.ts (limited to 'src/server/api/endpoints') diff --git a/src/server/api/endpoints/endpoint.ts b/src/server/api/endpoints/endpoint.ts new file mode 100644 index 0000000000..48e78cd04c --- /dev/null +++ b/src/server/api/endpoints/endpoint.ts @@ -0,0 +1,26 @@ +import $ from 'cafy'; +import define from '../define'; +import endpoints from '../endpoints'; + +export const meta = { + requireCredential: false, + + tags: ['meta'], + + params: { + endpoint: { + validator: $.str, + } + }, +}; + +export default define(meta, async (ps) => { + const ep = endpoints.find(x => x.name === ps.endpoint); + if (ep == null) return null; + return { + params: Object.entries(ep.meta.params || {}).map(([k, v]) => ({ + name: k, + type: v.validator.name === 'ID' ? 'String' : v.validator.name + })) + }; +}); -- cgit v1.2.3-freya