Genesis
This commit is contained in:
19
src/api/routes/auth/me.js
Normal file
19
src/api/routes/auth/me.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { meJson } from './meJson.js';
|
||||
|
||||
/**
|
||||
* Registers the current-user route (requires prior auth middleware populating `req.user`).
|
||||
* @param {import('express').Application} app - Express app
|
||||
* @param {string} [basePath=''] - Optional URL prefix for all routes in this module
|
||||
*/
|
||||
export function register(app, basePath = '') {
|
||||
/**
|
||||
* @route GET /auth/me
|
||||
* @description Returns the authenticated user from `req.user` and the Google client ID.
|
||||
* @returns {Object} 200 - `{ user: { id, email, picture? }, googleClientId }`
|
||||
*/
|
||||
app.get(`${basePath}/auth/me`, (req, res) => {
|
||||
const { id, email, picture } = req.user;
|
||||
const user = { id, email, ...(picture && { picture }) };
|
||||
meJson(res, 200, { user });
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user