MCPcopy Create free account
hub / github.com/ether/etherpad / expressPreSession

Function expressPreSession

src/node/hooks/express/openapi-admin.ts:187–209  ·  view source on GitHub ↗
(
  _hookName: string,
  {app}: ArgsExpressType,
)

Source from the content-addressed store, hash-verified

185exports.generateAdminDefinition = generateAdminDefinition;
186
187export 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
211exports.expressPreSession = expressPreSession;

Callers

nothing calls this directly

Calls 2

generateAdminDefinitionFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected