mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
Add interface to view post and user JSON data
This commit is contained in:
parent
342a8011f1
commit
db37510370
21 changed files with 248 additions and 122 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export const meta = applyConfig({
|
|||
max: 4,
|
||||
duration: 60,
|
||||
},
|
||||
route: "/auth/login",
|
||||
route: "/api/auth/login",
|
||||
auth: {
|
||||
required: false,
|
||||
},
|
||||
|
|
@ -8,7 +8,7 @@ export const meta = applyConfig({
|
|||
max: 4,
|
||||
duration: 60,
|
||||
},
|
||||
route: "/auth/redirect",
|
||||
route: "/api/auth/redirect",
|
||||
auth: {
|
||||
required: false,
|
||||
},
|
||||
|
|
@ -13,7 +13,7 @@ export const meta = applyConfig({
|
|||
},
|
||||
route: "/api/v1/accounts/:id",
|
||||
auth: {
|
||||
required: true,
|
||||
required: false,
|
||||
oauthPermissions: [],
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue