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

@ -37,15 +37,16 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/ad/update'> {
name = 'admin/ad/update' as const;
constructor(
@Inject(DI.adsRepository)
private adsRepository: AdsRepository,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
const ad = await this.adsRepository.findOneBy({ id: ps.id });
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
if (ad == null) throw new ApiError(this.meta.errors.noSuchAd);
await this.adsRepository.update(ad.id, {
url: ps.url,

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',
})),

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,
@ -29,13 +29,16 @@ export const paramDef = {
required: [],
} as const;
// !!!!!!!!!!!!!!!!!!!!!!!!DONE!!!!!!!!!!!!!!!!!!!!!!!!!!!
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'endpoints'> {
name = 'endpoints' as const;
constructor(
) {
super(meta, paramDef, async () => {
return endpoints.map(x => x.name);
super(async () => {
return Object.keys(endpoints);
});
}
}