-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
43 lines (34 loc) · 1.01 KB
/
app.js
File metadata and controls
43 lines (34 loc) · 1.01 KB
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
39
40
41
42
43
const cors = require("cors");
const corsOptions = {
origin: "*",
optionSuccessStatus: 200,
};
// initial code
require("dotenv").config();
const express = require("express");
var https = require("https");
var fs = require("fs");
//Database connection
const UthaanDB = require("./src/config/db.js");
const cloudinary = require("./src/config/cloudinary.js");
const auth = require("./src/routes/auth");
const api = require("./src/routes/api");
const app = express();
app.use(express.json());
app.use(cors(corsOptions));
const port = process.env.PORT || 8000;
//Route to fetch data
app.use("/api", api);
//Route for admin auth actions
app.use("/auth", auth);
// let httpsServer = https.createServer({
// key: fs.readFileSync('server-key.pem'),
// cert: fs.readFileSync('server-cert.pem')
// },app);
// httpsServer.listen(8080);
app.listen(process.env.PORT || port, () => {
console.log(`Server running at port ${port}`);
});
app.get("/", (req, res) => {
res.send("Server is up and running at port " + port);
});