-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
48 lines (36 loc) · 1.07 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
const express = require('express');
const bcrypt = require('bcrypt-nodejs');
const cors = require('cors');
const knex = require('knex');
const register =require('./controlllers/register');
const signin = require('./controlllers/signin');
const profile =require('./controlllers/profile');
const imageurl=require('./controlllers/imageurl');
require('dotenv').config();
const db = knex({
client: 'pg',
connection:`${process.env.DATABASE_URL}`,
});
const app = express();
app.use(cors())
app.use(express.json());
app.get('/', async(req, res)=> {
const data= await db.select('*').from('users');
console.log(data);
res.send('hello');
});
app.post('/imageurl', (req, res) => {
imageurl.handleImageUrl(req, res);
});
app.post('/signin', (req, res) => {
signin.handleSignin(req, res, bcrypt, db);
});
app.post('/register', (req, res) => {
register.handleRegister(req, res, db, bcrypt);
});
app.get('/profile/:id', (req, res) => {
profile.handleProfileGet(req, res, db);
});
app.listen( process.env.PORT||3000, ()=> {
console.log(`app is running on port ${process.env.PORT} `);
});