change and fix
This commit is contained in:
parent
0ea386effe
commit
14df563c7d
|
|
@ -1,6 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: tamaina and other misskey contributors
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Never use `./error.js` because jest can't use it.
|
|
||||||
|
|
@ -4,17 +4,10 @@
|
||||||
*/
|
*/
|
||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
|
|
||||||
export function ErrorHandling(message: string, reply?: FastifyReply, statusCode?: number): Error {
|
export async function ErrorHandler(error: Error, request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
||||||
const error = new Error(message);
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
error.stack = undefined;
|
error.stack = undefined;
|
||||||
}
|
}
|
||||||
if (reply) {
|
reply.send(error);
|
||||||
reply.code(statusCode ?? 500);
|
throw error;
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ErrorHandler(error: Error, request: FastifyRequest, reply: FastifyReply): void {
|
|
||||||
throw ErrorHandling(error.message, reply);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export class FastifyReplyError extends Error {
|
||||||
this.statusCode = statusCode;
|
this.statusCode = statusCode;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
Object.defineProperty(this, 'stack', { value: '' });
|
Object.defineProperty(this, 'stack', { value: undefined });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,6 @@ export class OAuth2ProviderService {
|
||||||
public async createServer(fastify: FastifyInstance): Promise<void> {
|
public async createServer(fastify: FastifyInstance): Promise<void> {
|
||||||
// https://datatracker.ietf.org/doc/html/rfc8414.html
|
// https://datatracker.ietf.org/doc/html/rfc8414.html
|
||||||
// https://indieauth.spec.indieweb.org/#indieauth-server-metadata
|
// https://indieauth.spec.indieweb.org/#indieauth-server-metadata
|
||||||
|
|
||||||
fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => {
|
fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => {
|
||||||
reply.send({
|
reply.send({
|
||||||
issuer: this.config.url,
|
issuer: this.config.url,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue