Skip to content

Commit

Permalink
feat: me endpoint
Browse files Browse the repository at this point in the history
Add me endpoint to get current user
  • Loading branch information
marcobiedermann committed Jul 5, 2020
1 parent 4c0358d commit 659060b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/index.ts
Expand Up @@ -4,6 +4,7 @@ import authRoutes from './auth';
import connectRoutes from './connect';
import healthcheck from './healthcheck';
import logoutRoutes from './logout';
import meRoutes from './me';
import organizationRoutes from './organization';
import teamRoutes from './team';
import userRoutes from './user';
Expand All @@ -17,6 +18,7 @@ router.use(authRoutes);
router.use(connectRoutes);
router.use(healthcheck);
router.use(logoutRoutes);
router.use(meRoutes);
router.use(organizationRoutes);
router.use(teamRoutes);
router.use(userRoutes);
Expand Down
17 changes: 17 additions & 0 deletions src/routes/me/index.ts
@@ -0,0 +1,17 @@
import { Request, Response, Router } from 'express';
import asyncHandler from 'express-async-handler';
import passport from 'passport';

const router = Router();

async function getMe(request: Request, response: Response) {
const { user } = request;

response.json({
user,
});
}

router.route('/me').get(passport.authenticate('basic'), asyncHandler(getMe));

export default router;

0 comments on commit 659060b

Please sign in to comment.