-
Notifications
You must be signed in to change notification settings - Fork 16
/
app.js
43 lines (30 loc) · 964 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
39
40
41
42
43
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import { connectDB } from "./src/config/db.config.js";
import {v2 as cloudinary} from 'cloudinary';
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
dotenv.config();
const app = express();
import api from "./src/routes/api.js";
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.use("/api", api);
const PORT = parseInt(process.env.PORT) || 5000;
app.get("/", (req, res) => {
res.send("Hello World");
console.log(process.env.JWT_KEY);
});
app.use((err, req, res, next) => {
let { status = 500, message = "Something Went Wrong!" } = err;
res.status(status).render("error.ejs", { message });
});
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}! 🚀`);
connectDB();
});