Add interface to view post and user JSON data

This commit is contained in:
Jesse Wierzbinski 2024-04-08 18:33:59 -10:00
parent 342a8011f1
commit db37510370
No known key found for this signature in database
21 changed files with 248 additions and 122 deletions

View file

@ -17,5 +17,5 @@ export const meta = applyConfig({
* Default catch-all route, returns a 404 error.
*/
export default apiRoute(() => {
return errorResponse("This API route does not exist", 404);
return errorResponse("Route not found", 404);
});

View file

@ -10,7 +10,7 @@ export const meta = applyConfig({
max: 4,
duration: 60,
},
route: "/auth/login",
route: "/api/auth/login",
auth: {
required: false,
},

View file

@ -8,7 +8,7 @@ export const meta = applyConfig({
max: 4,
duration: 60,
},
route: "/auth/redirect",
route: "/api/auth/redirect",
auth: {
required: false,
},

View file

@ -13,7 +13,7 @@ export const meta = applyConfig({
},
route: "/api/v1/accounts/:id",
auth: {
required: true,
required: false,
oauthPermissions: [],
},
});

View file

@ -12,7 +12,7 @@ export const meta = applyConfig({
duration: 60,
},
auth: {
required: true,
required: false,
oauthPermissions: ["read:accounts"],
},
});
@ -25,11 +25,6 @@ export default apiRoute<{
following?: boolean;
}>(async (req, matchedRoute, extraData) => {
// TODO: Add checks for disabled or not email verified accounts
const { user } = extraData.auth;
if (!user) return errorResponse("Unauthorized", 401);
const {
following = false,
limit = 40,
@ -37,6 +32,10 @@ export default apiRoute<{
q,
} = extraData.parsedRequest;
const { user } = extraData.auth;
if (!user && following) return errorResponse("Unauthorized", 401);
if (limit < 1 || limit > 80) {
return errorResponse("Limit must be between 1 and 80", 400);
}
@ -60,7 +59,7 @@ export default apiRoute<{
relationshipSubjects: following
? {
some: {
ownerId: user.id,
ownerId: user?.id,
following,
},
}