From 7cb6f419fb21cbf9f9d3a8548abbbc82ad451206 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 17 Nov 2020 11:15:20 +0100 Subject: [PATCH] Add index page --- api/src/scheduler/index.ts | 2 ++ api/src/scheduler/routes/index.ts | 46 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 api/src/scheduler/routes/index.ts diff --git a/api/src/scheduler/index.ts b/api/src/scheduler/index.ts index 590773ddd..f111566e8 100644 --- a/api/src/scheduler/index.ts +++ b/api/src/scheduler/index.ts @@ -18,6 +18,7 @@ import cors from "fastify-cors"; import telemetry from "./telemetry"; import sentryPlugin from "./sentry"; import loggerPlugin from "./logger"; +import indexRoute from "./routes/index"; import { StructuredLogger } from "../shared/structured-logger"; import { Logger } from "../shared/logger"; @@ -94,6 +95,7 @@ export async function createServer({ app.register(usageRoute, { prefix: "/usage" }); } + app.register(indexRoute); app.register(health, { prefix: "/health" }); app.register(queues, { prefix: "/queues" }); app.register(activityPlugin, { prefix: "/activity" }); diff --git a/api/src/scheduler/routes/index.ts b/api/src/scheduler/routes/index.ts new file mode 100644 index 000000000..7d21f0cc3 --- /dev/null +++ b/api/src/scheduler/routes/index.ts @@ -0,0 +1,46 @@ +import { FastifyPluginCallback } from "fastify"; + +const welcomePage = ` +

+Welcome to the Quirrel API! +

+ +

+As an end-user, you're most likely looking for something else: +

+ + + +

+If you didn't get here by accident, but want to interface directly with the Quirrel API, +take a look at the OpenAPI spec: +

+ + +`.trim(); + +const index: FastifyPluginCallback = (fastify, opts, done) => { + fastify.get("/", (request, reply) => { + reply.status(200).header("Content-Type", "text/html").send(welcomePage); + }); + done(); +}; + +export default index;