3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 07:35:02 +00:00

Dashboard work and related

This commit is contained in:
Dragory 2019-06-23 19:18:41 +03:00
parent 5279ab06fa
commit 1ecce52973
44 changed files with 637 additions and 272 deletions

View file

@ -1,9 +1,12 @@
import { error, notFound } from "./responses";
require("dotenv").config();
import express from "express";
import cors from "cors";
import { initAuth } from "./auth";
import { initGuildsAPI } from "./guilds";
import { initArchives } from "./archives";
import { connect } from "../data/db";
console.log("Connecting to database...");
@ -19,16 +22,23 @@ connect().then(() => {
initAuth(app);
initGuildsAPI(app);
initArchives(app);
app.use((err, req, res, next) => {
res.status(err.status || 500);
res.json({ error: err.message });
});
// Default route
app.get("/", (req, res) => {
res.end({ status: "cookies" });
});
// Error response
app.use((err, req, res, next) => {
error(res, err.message, err.status || 500);
});
// 404 response
app.use((req, res, next) => {
return notFound(res);
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`API server listening on port ${port}`));
});