mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
37 lines
881 B
TypeScript
37 lines
881 B
TypeScript
import { apiRoute, applyConfig } from "@api";
|
|
import { errorResponse, jsonResponse } from "@response";
|
|
import { client } from "~database/datasource";
|
|
import { userToLysand } from "~database/entities/User";
|
|
import { userRelations } from "~database/entities/relations";
|
|
|
|
export const meta = applyConfig({
|
|
allowedMethods: ["POST"],
|
|
auth: {
|
|
required: false,
|
|
},
|
|
ratelimits: {
|
|
duration: 60,
|
|
max: 500,
|
|
},
|
|
route: "/users/:uuid",
|
|
});
|
|
|
|
/**
|
|
* ActivityPub user inbox endpoint
|
|
*/
|
|
export default apiRoute(async (req, matchedRoute) => {
|
|
const uuid = matchedRoute.params.uuid;
|
|
|
|
const user = await client.user.findUnique({
|
|
where: {
|
|
id: uuid,
|
|
},
|
|
include: userRelations,
|
|
});
|
|
|
|
if (!user) {
|
|
return errorResponse("User not found", 404);
|
|
}
|
|
|
|
return jsonResponse(userToLysand(user));
|
|
});
|