-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
56 lines (49 loc) · 1.11 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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cors = require('cors');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(cors());
app.use('/users', require('./api/users/user'));
app.use('/auth', require('./api/auth/auth'));
app.post('/testLogin', (req, res)=>{
return res.status(200).json({
'data': {
'token': 'this_is_token',
'refresh_token': 'this_is_refresh_token'
},
'status': 200,
'msg': 'success'
});
});
app.post('/testRefreshToken', (req, res)=>{
return res.status(200).json({
'data':{
'token' : 'new_token',
},
'status': 200,
});
});
app.post('/testCall', (req, res)=>{
console.log(req.headers.token);
if(req.headers.token!=='new_token'){
return res.status(401).json({
'data':{
'data' : '인증 안됨',
},
'status': 401,
});
}
return res.status(200).json({
'data':{
'data' : 'test_call_success',
},
'status': 200,
});
});
app.listen(3000, () => {
console.log('3000 포트 열기 !');
});