This commit is contained in:
seb
2026-06-23 11:04:07 +02:00
commit 667f498573
19 changed files with 4299 additions and 0 deletions

19
src/api/routes/auth/me.js Normal file
View 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 });
});
}