Skip to content

Commit

Permalink
add avatar endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
coolchock committed Nov 18, 2024
1 parent afb1c26 commit 6d65961
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/src/routes/avatar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import express, {Request, Response} from 'express';
import UserMetadata from 'supertokens-node/recipe/usermetadata';
import {logger} from '../utilities/logger';

const router = express.Router();

router.get('/avatar', async (req: Request, res: Response) => {
logger.debug('api avatar route hit');
// @ts-ignore
const session = req.session;
const userId = session.getUserId();
const {metadata} = await UserMetadata.getUserMetadata(userId);
const avatarUrl = metadata.avatarUrl;
if (avatarUrl) {
res.json({avatarUrl: avatarUrl});
} else {
res.json({avatarUrl: null});
}
});

export default router;

0 comments on commit 6d65961

Please sign in to comment.