* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* Update SignupApiService.ts

* wip

* wip

* Update ClientServerService.ts

* wip

* wip

* wip

* Update WellKnownServerService.ts

* wip

* wip

* update des

* wip

* Update ApiServerService.ts

* wip

* update deps

* Update WellKnownServerService.ts

* wip

* update deps

* Update ApiCallService.ts

* Update ApiCallService.ts

* Update ApiServerService.ts
This commit is contained in:
syuilo 2022-12-03 19:42:05 +09:00 committed by GitHub
parent 2db9f6efe7
commit 3a7182bfb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 1651 additions and 1977 deletions

View file

@ -1,5 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import Router from '@koa/router';
import { FastifyInstance, FastifyPluginOptions, FastifyReply, FastifyRequest } from 'fastify';
import { IsNull, MoreThan } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { NotesRepository, UsersRepository } from '@/models/index.js';
@ -27,6 +27,7 @@ export class NodeinfoServerService {
private userEntityService: UserEntityService,
private metaService: MetaService,
) {
this.createServer = this.createServer.bind(this);
}
public getLinks() {
@ -39,9 +40,7 @@ export class NodeinfoServerService {
}];
}
public createRouter() {
const router = new Router();
public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) {
const nodeinfo2 = async () => {
const now = Date.now();
const [
@ -108,22 +107,22 @@ export class NodeinfoServerService {
const cache = new Cache<Awaited<ReturnType<typeof nodeinfo2>>>(1000 * 60 * 10);
router.get(nodeinfo2_1path, async ctx => {
fastify.get(nodeinfo2_1path, async (request, reply) => {
const base = await cache.fetch(null, () => nodeinfo2());
ctx.body = { version: '2.1', ...base };
ctx.set('Cache-Control', 'public, max-age=600');
reply.header('Cache-Control', 'public, max-age=600');
return { version: '2.1', ...base };
});
router.get(nodeinfo2_0path, async ctx => {
fastify.get(nodeinfo2_0path, async (request, reply) => {
const base = await cache.fetch(null, () => nodeinfo2());
delete (base as any).software.repository;
ctx.body = { version: '2.0', ...base };
ctx.set('Cache-Control', 'public, max-age=600');
reply.header('Cache-Control', 'public, max-age=600');
return { version: '2.0', ...base };
});
return router;
done();
}
}