-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (45 loc) · 1.81 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const bodyparser = require("body-parser");
require('dotenv').config();
const multerMid = require("./Middlewears/Multer")
const multerReelMid = require("./Middlewears/ReelMulter")
const { RegisterHangle, LoginHandler, GetProfile,GetProfilebyUsername,
AddprofilePic, Addabout, CompleteProfile, EditProfile,FollowController } = require("./Controllers/UserController");
const { CreatePost, getPosts, DeltePost, GetPostbyId
, EditPost, AddLike, Addcomment } = require("./Controllers/PostController");
const { CreatereelController, getReels } = require("./Controllers/ReelsController");
const app = express();
app.use(cors());
app.use(bodyparser.json());
port = 4599;
const url = process.env.DB_Url;
if (mongoose.connect(url)) {
console.log("Db connected")
}
else {
console.log("Db not connected")
}
//user section
app.get("/user/GetProfile", GetProfile);
app.get("/user/GetProfilebyusername", GetProfilebyUsername);
app.post("/user/register", RegisterHangle);
app.post("/user/login", LoginHandler);
app.post("/user/addprofilepic", multerMid, AddprofilePic);
app.post("/user/addabout", Addabout);
app.post("/user/completeprofile", CompleteProfile);
app.post("/user/follow", FollowController);
app.put("/user/editprofile", EditProfile)
// Post section
app.post("/post/CreatePost", multerMid, CreatePost);
app.post("/post/AddLike", AddLike);
app.post("/post/addcomment", Addcomment);
app.delete("/post/DeltePost", DeltePost);
app.put("/post/EditPost", multerMid, EditPost);
app.get("/post/getPosts", getPosts);
app.get("/post/GetPostbyId", GetPostbyId);
// Reels section
app.post("/reels/create", multerReelMid, CreatereelController)
app.get("/reels/getreels", getReels)
app.listen(port, console.log(`port started on ${port}`))