-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (21 loc) · 835 Bytes
/
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
const express = require('express');
const cors = require('cors');
const PORT = process.env.PORT || 3000;
const { authenticateUser } = require('./middlewares/auth-user');
const { handleRegister, handleSignIn } = require('./controllers/auth');
const { handleGetUserProfile } = require('./controllers/profile');
const { handleImage, handleApiCall } = require('./controllers/image');
const app = express();
app.use(cors());
app.use(express.json());
app.get('/', (req, res) => {
res.json('Hello!');
});
app.get('/profile/:id', authenticateUser, handleGetUserProfile);
app.post('/sign-in', handleSignIn);
app.post('/register', handleRegister);
app.post('/image-url', authenticateUser, handleApiCall);
app.put('/image', authenticateUser, handleImage);
app.listen(PORT, () => {
console.log('App is listening on port 3000..');
});