This repository was archived by the owner on Sep 2, 2025. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
Latest commit
35 lines (28 loc) · 1.14 KB
/
Copy pathserver.js
File metadata and controls
35 lines (28 loc) · 1.14 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
constexpress=require('express');
constbodyParser=require('body-parser');
constcors=require('cors');
constbcrypt=require('bcrypt-nodejs');
constknex=require('knex');
constregister=require('./controllers/register');
constsignin=require('./controllers/signin');
constimage=require('./controllers/image');
constprofile=require('./controllers/profile');
constPORT=process.env.PORT||3000
constDATABASE_URL=process.env.DATABASE_URL
constdb=knex({
client: 'pg',
connection: {
connectionString : DATABASE_URL,
ssl: true
}
});
constapp=express();
app.use(cors());
app.use(bodyParser.json());
app.get('/',(req,res)=>res.send('you have found the server congrats..'))
app.post('/signin',(req,res)=>signin.handleSignin(req,res,db,bcrypt))
app.post('/register',(req,res)=>register.handleRegister(req,res,db,bcrypt))
app.put('/image',(req,res)=>image.handleImage(req,res,db))
app.post('/imageurl',(req,res)=>{image.handleApiCall(req,res)})
app.get('/profile/:userID',(req,res)=>profile.handleProfileGet(req,res,db))
app.listen(PORT,()=>console.log(`server is listening on ${PORT}`))