Serves sign-up and user profiles, with what each user posted, upvoted, made,
follows and invited, and the dumps and playlists under them. A user's :key
is their id or @name, a current or former name in any case
(resolveUserKey). A profile sent to anyone goes through toPublicUser,
which drops the email. The caller's own account is routes/me.ts's.
POST /api/users— public, with a valid invite. Creates an account, sends the welcome email, and answers the user and their tokens.GET /api/users?q=— public. Answers up to 8 users whose name starts withq, for @mention suggestions.GET /api/users/:key— public. Answers a user's profile.GET /api/users/:key/dumps?page=&limit=&category=— optional sign-in. Answers a page of their dumps, the private ones only to themselves, optionally in one category.GET /api/users/:key/dumps/:slug— optional sign-in. Answers their dump whose slug is or wasslug, with its current slug; a private one 404s but for its poster.GET /api/users/:key/upvoted?page=&limit=&category=— optional sign-in. Answers a page of the dumps they upvoted, private ones only to themselves, optionally in one category.GET /api/users/:key/playlists?page=&limit=&category=&sort=— optional sign-in. Answers a page of the playlists they made, the private ones only to themselves, optionally in one playlist category, in the ordersortnames, asGET /api/playlistsdoes.GET /api/users/:key/playlists/:slug— optional sign-in. Answers their playlist whose slug is or wasslug, with its current slug and the dumps the caller may see; a private one 404s but for its owner.GET /api/users/:key/follow/users?page=&limit=— public. Answers a page of the users they follow.GET /api/users/:key/follow/playlists?page=&limit=— public. Answers a page of the public playlists they follow.GET /api/users/:key/invitees— public. Answers the tree of users they invited.GET /api/users/:key/home?path=— public. Redirects to a page of the instance a user from another instance comes from, their profile there unlesspathnames another; a local user 404s.PATCH /api/users/:key/role— permissionuser:manage. Sets another user's role.PATCH /api/users/:key/username— permissionuser:manage. Renames a user, the caller included. It is the only way a local name changes; a user from another instance is named there (400). The instances the user signed in to are told.
v
default: Router
Mounted by api/main.ts behind the error, Open Graph and CORS middleware.
An APIException thrown by a handler becomes the JSON error response there.
Usage
import * as mod from "api/routes/users.ts";