-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (35 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
import express, { response } from 'express';
import bodyParser from 'body-parser';
import bcrypt from 'bcrypt-nodejs';
import cors from 'cors';
import _knex from 'knex';
import handleRegister from './controllers/register.js';
import handleProfile from './controllers/profile.js';
import handleSignin from './controllers/signin.js';
import { handleImage } from './controllers/imageHandler.js';
import { handleApiCall } from './controllers/imageHandler.js';
const db = _knex({
client: 'pg',
connection: process.env.DATABASE_URL,
});
const app = express();
app.use(bodyParser.json());
app.use(cors());
app.post('/signin', (req, res) => {
handleSignin(req, res, db, bcrypt);
});
app.post('/register', (req, res) => {
handleRegister(req, res, db, bcrypt);
});
app.get('/profile/:id', (req, res) => {
handleProfile(req, res, db);
});
app.put('/image', (req, res) => {
handleImage(req, res, db);
});
app.post('/imageurl', (req, res) => {
handleApiCall(req, res);
});
app.listen(process.env.PORT || 3000, () => {
console.log(`App is running on port ${process.env.PORT || 3000}`);
});