-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
58 lines (39 loc) · 1.46 KB
/
app.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
const express = require('express');
const cors = require('cors');
const expressFileUpload = require('express-fileupload');
const cloudinary = require('cloudinary').v2;
require('dotenv').config();
const { json, urlencoded } = require('body-parser');
const authRoute = require('./routes/auth');
const userRoute = require('./routes/userRoute');
const usersRoute = require('./routes/usersRoutes');
const articlesRoute = require('./routes/postsRoute');
const gifRoute = require('./routes/gifRoute');
const uploadRoute = require('./routes/uploadRoute');
const commentsRoute = require('./routes/commentsRoute');
const app = express();
cloudinary.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
app.use(cors());
app.use(express.static('public'));
app.use(json({ limit: '50mb' }));
app.use(urlencoded({ limit: '50mb', extended: true }));
app.use(expressFileUpload({ useTempFiles: true }));
app.use('/api/v1', authRoute);
app.use('/api/v1', userRoute);
app.use('/api/v1', usersRoute);
app.use('/api/v1', articlesRoute);
app.use('/api/v1', gifRoute);
app.use('/api/v1', uploadRoute);
app.use('/api/v1', commentsRoute);
app.get('/', (req, res) => res.status(200).json({ message: 'welcome to my api' }));
app.all('*', (req, res) => res.status(404).json({
message: 'route not found'
}));
const PORT = process.env.PORT || 5001;
app.listen(PORT, () => {
console.log('server started...');
});