forked from gaurav-b-singh/events-galore-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
62 lines (45 loc) · 1.25 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const dotenv = require("dotenv");
dotenv.config({ path: "./config.env" });
const cookieParser = require("cookie-parser");
const express = require("express");
const mongoose = require("mongoose");
const app = express();
const { cloudinary } = require("./utils/cloudinary");
require("./db/conn");
app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ limit: '50mb', extended: true }));
app.use(express.json());
app.use(cookieParser());
app.use(require("./router/auth"));
// app.get("/", (req, res) => {
// res.send("HELLO THERE");
// });
// const middleware = (req, res, next) => {
// console.log("hello middle");
// next();
// };
app.get("/createv", (req, res) => {
res.send("CREATE EVENT");
});
app.get("/event", (req, res) => {
res.send("EVENTS:");
});
app.listen(2000, () => {
console.log("server is running");
});
app.use(express.static("public"));
let imageurl = "";
app.post("/image", async (req, res) => {
try {
const fileStr = req.body.data;
const uploadResponse = await cloudinary.uploader.upload(fileStr, {
upload_preset: "eventimages",
});
imageurl = uploadResponse.url;
res.send(imageurl);
console.log(imageurl);
} catch (err) {
console.error(err);
}
});
app.get("/image", (req, res) => res.send({ imageurl }));