Skip to content

Commit

Permalink
Merge pull request #26 from quirrel-dev/human-friendly-index
Browse files Browse the repository at this point in the history
Add index page
  • Loading branch information
Skn0tt authored Nov 17, 2020
2 parents e06c0d3 + 7cb6f41 commit b72891d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/src/scheduler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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" });
Expand Down
46 changes: 46 additions & 0 deletions api/src/scheduler/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FastifyPluginCallback } from "fastify";

const welcomePage = `
<h1>
Welcome to the Quirrel API!
</h1>
<p>
As an end-user, you're most likely looking for something else:
</p>
<ul>
<li>
<a href="https://quirrel.dev">Landing Page</a>
</li>
<li>
<a href="https://docs.quirrel.dev">Documentation</a>
</li>
<li>
<a href="https://github.com/quirrel-dev">Github</a>
</li>
</ul>
<p>
If you didn't get here by accident, but want to interface directly with the Quirrel API,
take a look at the OpenAPI spec:
</p>
<ul>
<li>
<a href="/documentation">Swagger Docs</a>
</li>
<li>
<a href="/documentation/docs.html">ReDocs</a>
</li>
</ul>
`.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;

0 comments on commit b72891d

Please sign in to comment.