|
|
const express = require("express"); |
|
|
const bodyParser = require("body-parser"); |
|
|
const webhookRoutes = require("./webhook"); |
|
|
|
|
|
require("dotenv").config(); |
|
|
|
|
|
const app = express(); |
|
|
app.use(bodyParser.json()); |
|
|
|
|
|
|
|
|
|
|
|
app.use((req, res, next) => { |
|
|
if (req.path.substr(-1) === "/" && req.path.length > 1) { |
|
|
res.redirect(301, req.path.slice(0, -1)); |
|
|
} else { |
|
|
next(); |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
app.use("/webhook", webhookRoutes); |
|
|
app.get("/test", (req, res) => { |
|
|
res.send("Test route works!"); |
|
|
}); |
|
|
|
|
|
app.get("/", (req, res) => { |
|
|
res.status(200).send("Home route works!"); |
|
|
}); |
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 3000; |
|
|
app.listen(PORT, () => { |
|
|
console.log(`Server running on port ${PORT}`); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|