-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
38 lines (33 loc) · 1013 Bytes
/
app.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
const express = require("express");
const app = express();
const team = require("./models/team");
const event = require("./models/Events_Page");
// const axios = require("axios");
// const { expressjwt: expressJwt } = require("express-jwt");
// const jwks = require("jwks-rsa");
const cors = require("cors");
const connectDB = require("./db/connect");
const mongoose = require("mongoose");
require("dotenv").config();
app.use(cors());
app.use(express.json());
app.post("/api/v1/team", async (req, res) => {
const Team = await team.create(req.body);
res.status(201).json({ Team });
});
app.post("/api/v1/event", async (req, res) => {
const Event = await event.create(req.body);
res.status(201).json({ Event });
});
const port = process.env.PORT || 4000;
const start = async () => {
try {
await connectDB(process.env.MONGO_URI);
app.listen(port, () => {
console.log(`server is listenning on ${port}`);
});
} catch (error) {
console.log(error);
}
};
start()