Skip to content

Commit

Permalink
Adding a monitor endpoint to ensure 100% uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoBeee committed Jan 24, 2024
1 parent b1129ad commit 9ae2feb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions SwiftLinkAPI/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require("express");
const dotenv = require("dotenv");
const cors = require("cors");
const requestIp = require('request-ip');
const requestIp = require("request-ip");

const urlRouter = require("./routes/URL.route");
const urlRedirectRouter = require("./routes/RedirectURLViewer.route");
Expand All @@ -19,14 +19,21 @@ app.use(express.json());
// app.set("trust proxy", true);

// Using requestIp lib to get IP from behind the proxy
app.use(requestIp.mw())
app.use(requestIp.mw());

// Create Short URL ID
app.use("/url", urlRouter);

// Find and Redirect to Original URL
app.use("/", urlRedirectRouter);

// For personal use (pinging the server at intervals of every 5 minutes to ensure 100% uptime)
app.use("/monitor", (req, res) => {
res.status(httpStatusCodes.OK).send({
ok: true,
});
});

// Show an error if user trying to access a resource that doesn't exist.
app.use((req, res) => {
res.status(httpStatusCodes.NOT_FOUND).send({
Expand Down

0 comments on commit 9ae2feb

Please sign in to comment.