-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 966 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
//modules
require("dotenv").config({ path: './.env' });
const express = require("express");
const app = express();
const cors = require("cors");
const connection = require("./db");
// routes
const userRoutes = require("./routes/user");
const authRoutes = require("./routes/auth");
const strainRoutes = require("./routes/strain");
// Database
connection();
// middleware
app.use(express.json());
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, PATCH, DELETE, OPTIONS');
next();
});
app.use("/api/users", userRoutes);
app.use("/api/auth", authRoutes);
app.use("/api/strains", strainRoutes);
app.get("/", (req, res) => {
return res.status(200);
});
const PORT = process.env.PORT || 2000;
app.listen(PORT, () => console.log(`Listening on port ${PORT}...`));