-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
75 lines (63 loc) · 1.72 KB
/
server.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
65
66
67
68
69
70
71
72
73
74
75
const express = require('express');
const bodyParser = require('body-parser');
const bcrypt = require('bcrypt-nodejs');
const cors = require('cors');
const knex = require('knex')
const register = require('./controllers/register');
const signin = require('./controllers/signin');
const profile = require('./controllers/profile');
const image = require('./controllers/image');
const db = knex({
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : 'test',
database : 'facedetection'
}
});
const app = express();
app.use(bodyParser.json())
app.use(cors())
const dataBase ={
users:[
{
id:'123',
name:'walaa',
email:'walaa@gmail.com',
password:'walaa@1997',
entries:0,
joined: new Date()
},
{
id:'1234',
name:'ahmed',
email:'ahmed@gmail.com',
password:'ahmed@1997',
entries:0,
joined: new Date()
}
]
}
app.get('/',(req, res)=>{res.send(dataBase.users);
});
app.post('/signin',(req,res)=>{signin.handleSignin(req ,res , bcrypt ,db) //pass to handleSignin
})
app.post('/register' ,(req,res)=> {register.handleRegister(req ,res , bcrypt ,db) //pass to handleregister
})
app.get('/profile/:id',(req, res)=>{profile.handleProfile(req ,res , db) //pass to handleProfile
})
app.put('/image',(req,res)=>{image.handleImage(req ,res , db) //pass to handleImage
})
app.post('/imageurl',(req,res)=>{image.handleApiCall(req ,res) //pass to handleApiCall
})
app.listen(5000,()=>{
console.log("app is running on port 5000");
})
/*
/--> res = this is working
/signin --post = success/fail
/register--post = user
/profile user_id get user
/image end point put --> user object
*/