(
_hookName: string,
{app}: ArgsExpressType,
)
| 185 | exports.generateAdminDefinition = generateAdminDefinition; |
| 186 | |
| 187 | export const expressPreSession = async ( |
| 188 | _hookName: string, |
| 189 | {app}: ArgsExpressType, |
| 190 | ): Promise<void> => { |
| 191 | // Behind a feature flag, default off. Etherpad policy |
| 192 | // (CONTRIBUTING.md, AGENTS.MD) requires new features to ship disabled by |
| 193 | // default. The route is only useful for third-party tooling — codegen |
| 194 | // imports generateAdminDefinition() in-process and does not depend on it. |
| 195 | // |
| 196 | // The flag is checked per-request (not at registration time) so toggling |
| 197 | // settings.adminOpenAPI.enabled at runtime takes effect immediately and |
| 198 | // so test suites that share a long-lived Express agent can exercise both |
| 199 | // states without restarting the server. |
| 200 | app.get('/admin/openapi.json', (_req: any, res: any) => { |
| 201 | if (!settings.adminOpenAPI?.enabled) { |
| 202 | // Return JSON 404 (not the SPA's text/html catch-all) so callers get |
| 203 | // a clear "feature disabled" signal rather than an HTML page. |
| 204 | return res.status(404).type('application/json').send({error: 'Not Found'}); |
| 205 | } |
| 206 | res.header('Access-Control-Allow-Origin', '*'); |
| 207 | res.json(generateAdminDefinition()); |
| 208 | }); |
| 209 | }; |
| 210 | |
| 211 | exports.expressPreSession = expressPreSession; |
nothing calls this directly
no test coverage detected