mirror of
https://github.com/hex248/sprint.git
synced 2026-02-09 02:33:02 +00:00
add + remove users from organisation
This commit is contained in:
19
packages/backend/src/routes/user/by-username.ts
Normal file
19
packages/backend/src/routes/user/by-username.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { BunRequest } from "bun";
|
||||
import { getUserByUsername } from "../../db/queries";
|
||||
|
||||
// /user/by-username?username=someusername
|
||||
export default async function userByUsername(req: BunRequest) {
|
||||
const url = new URL(req.url);
|
||||
const username = url.searchParams.get("username");
|
||||
|
||||
if (!username) {
|
||||
return new Response("username is required", { status: 400 });
|
||||
}
|
||||
|
||||
const user = await getUserByUsername(username);
|
||||
if (!user) {
|
||||
return new Response(`User with username '${username}' not found`, { status: 404 });
|
||||
}
|
||||
|
||||
return Response.json(user);
|
||||
}
|
||||
Reference in New Issue
Block a user