-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
64 lines (54 loc) · 1.16 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
59
60
61
62
63
64
require('dotenv').config();
const express = require('express');
const app = express();
const cors = require('cors');
// App middleware
app.use(express.json());
app.use(cors());
// DB_connection
const db_connect = require('./connection/db_connect');
const search = require('./router/search');
const auth = require('./router/auth');
const message = require('./router/messages');
const token = require('./router/token');
const user = require('./router/user');
/**
* path: /
* request: get
*/
app.get('/', (req, res) => {
res.send('<h1>Hello!! This is backend API for blood Connect</h1>');
});
// App Routes
/**
* User Authentication
* path : /api/auth
*/
app.use('/api/auth', auth);
/**
* User Route
* path : /api/user/
*/
app.use('/api/user', user);
/**
* Search Query
* path : /api/search
*/
app.use('/api/search', search);
/**
* Messages
* path : /api/message
*/
app.use('/api/message', message);
/**
* Token Verification
* path : /api/token
*/
app.use('/api/token', token);
// Server Listening
const PORT = process.env.PORT || '80';
db_connect().finally(() => {
app.listen(PORT, () => {
console.log('server is running at port : ', PORT);
});
});