backend endpoints wip

This commit is contained in:
tamaina
2023-05-21 18:49:44 +00:00
parent 23545bcbbb
commit 8d1569567f
7 changed files with 80 additions and 840 deletions

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import endpoints from '../endpoints.js';
import endpoints from 'misskey-js/built/endpoints';
export const meta = {
requireCredential: false,
@@ -16,16 +16,22 @@ export const paramDef = {
required: ['endpoint'],
} as const;
// !!!!!!!!!!!!!!!!!!!!!!!!WIP!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!WIP!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!WIP!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!WIP!!!!!!!!!!!!!!!!!!!!!!!!!!!
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'endpoint'> {
name = 'endpoint' as const;
constructor(
) {
super(meta, paramDef, async (ps) => {
const ep = endpoints.find(x => x.name === ps.endpoint);
super(async (ps) => {
const ep = endpoints[ps.endpoint];
if (ep == null) return null;
return {
params: Object.entries(ep.params.properties ?? {}).map(([k, v]) => ({
params: Object.entries(ep.defines[0]['req']['properties'] ?? {}).map(([k, v]) => ({
name: k,
type: v.type ? v.type.charAt(0).toUpperCase() + v.type.slice(1) : 'string',
})),