-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
38 lines (28 loc) · 1010 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Allows us to grab data from ical urls
const fetch = require("node-fetch");
// Query parser
const qs = require("qs");
const express = require("express");
const getIcalRouter = require("./src/api/routers/get-ical.js");
const userRouter = require("./src/api/routers/user.js");
const groupRouter = require("./src/api/routers/group.js");
const calendarRouter = require("./src/api/routers/calendar.js");
const app = express();
// Defaults to port 8080 in development
const port = process.env.port || 8080;
// Routes all files in public relative to the root url
app.use(express.static("public"));
app.use(express.json());
app.use("/api/get-ical", getIcalRouter);
app.use("/api/user", userRouter);
app.use("/api/group", groupRouter);
app.use("/api/calendar", calendarRouter);
app.set("query parser", (str) => {
return qs.parse(str, {
/* custom options */
});
});
const server = app.listen(port, () => {
console.log(`TimeWeaver is running on port ${port}`);
});
module.exports = { app, server };