Skip to content

Commit a3073d0

Browse files
committed
twitch handler
1 parent 0b88bc5 commit a3073d0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/routes/user/user.controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ export class UsersController extends Controller {
5959
return usernames;
6060
}
6161

62+
@Get('/twitch/{twitchId}')
63+
public async getUsernameForTwitchId(
64+
@Path() twitchId: number,
65+
@Res() notFound: TsoaResponse<404, { message: string }>,
66+
): Promise<string | {message: string}> {
67+
const [user] = await db.select({username: users.name}).from(users).where(eq(users.twitchId, twitchId)).limit(1);
68+
if(!user) throw new Error("twitchId not found");
69+
return user.username;
70+
}
71+
72+
73+
6274
@Post('{username}/characters/update')
6375
public async requestUpdateNowForUser(
6476
@Path() username: string,

0 commit comments

Comments
 (0)