29 lines
1018 B
JavaScript
29 lines
1018 B
JavaScript
/**
|
|
* The API in maintenance: every `/public/v1` endpoint answers 503 with the
|
|
* notice already resolved to a language, which is exactly what the real one
|
|
* does while the flag is on.
|
|
*
|
|
* npm run mock:down
|
|
* PIREON_API_URL=http://localhost:4600/api npm run preview
|
|
*/
|
|
import { createServer } from 'node:http';
|
|
|
|
// Every /public/v1 endpoint answers 503 while the flag is on, with the notice
|
|
// already resolved to the request's language.
|
|
createServer((req, res) => {
|
|
res.statusCode = 503;
|
|
res.setHeader('content-type', 'application/json');
|
|
res.setHeader('Retry-After', '3600');
|
|
res.end(
|
|
JSON.stringify({
|
|
message: 'Estamos migrando el Gitea. Volvemos en un rato.',
|
|
maintenance: true,
|
|
locale: 'es',
|
|
since: '2026-08-25T09:00:00Z',
|
|
// Set here so the "back on" line gets exercised; the real API usually
|
|
// leaves this null.
|
|
until: '2026-08-25T18:00:00Z',
|
|
})
|
|
);
|
|
}).listen(4600, () => console.log('Mock API (maintenance) on http://localhost:4600/api'));
|