setFormatter(new JsonFormatter()); $logger->pushHandler($handler); $app = AppFactory::create(); $app->addRoutingMiddleware(); $app->addBodyParsingMiddleware(); $app->addErrorMiddleware($settings['app_env'] === 'development', true, true, $logger); $app->get('/healthz', function (Request $request, Response $response): Response { // Stub healthcheck. Later milestones extend this with `db` and `jobs` fields. $response->getBody()->write((string) json_encode(['status' => 'ok'])); return $response->withHeader('Content-Type', 'application/json'); }); $app->map( ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], '/{routes:.+}', function (Request $request, Response $response): Response { $response->getBody()->write((string) json_encode(['error' => 'not_found'])); return $response ->withHeader('Content-Type', 'application/json') ->withStatus(404); } ); $app->run();