@@ -54,25 +54,27 @@ app.use(session.createSessionMiddleware());
54
54
app . use ( express . static ( path . join ( __dirname , './public' ) ) ) ;
55
55
56
56
// Article APIs
57
- app . post ( '/api/article/:id ' , ( req , res ) => {
57
+ app . post ( '/api/article/*? ' , ( req , res ) => {
58
58
const func = 'app.post /api/article/:id' ;
59
59
console . log ( { file, func, params : req . params , body : req . body } ) ;
60
60
61
61
const { content } = req . body ;
62
62
63
- article . create ( req . params . id , content )
63
+ article . create ( req . params [ 0 ] , content )
64
64
. then ( result => res . send ( result ) )
65
65
. catch ( error => {
66
66
console . log ( { file, func, error } ) ;
67
67
res . status ( 403 ) . send ( error ) ;
68
68
} ) ;
69
69
} ) ;
70
70
71
- app . get ( '/api/article/:id ' , ( req , res ) => {
71
+ app . get ( '/api/article/*? ' , ( req , res ) => {
72
72
const func = 'app.get /api/article/:id' ;
73
73
console . log ( { file, func, params : req . params } ) ;
74
74
75
- article . read ( req . params . id )
75
+ console . log ( req . params ) ;
76
+
77
+ article . read ( req . params [ 0 ] )
76
78
. then ( result => {
77
79
console . log ( { file, func, result } ) ;
78
80
res . send ( result )
@@ -83,13 +85,13 @@ app.get('/api/article/:id', (req, res) => {
83
85
} ) ;
84
86
} ) ;
85
87
86
- app . put ( '/api/article/:id ' , ( req , res ) => {
88
+ app . put ( '/api/article/*? ' , ( req , res ) => {
87
89
const func = 'app.put /api/article/:id' ;
88
90
console . log ( { file, func, params : req . params , body : req . body } ) ;
89
91
90
92
const { content, rev } = req . body ;
91
93
92
- article . update ( req . params . id , content , rev )
94
+ article . update ( req . params [ 0 ] , content , rev )
93
95
. then ( result => res . send ( result ) )
94
96
. catch ( error => {
95
97
console . log ( { file, func, error } ) ;
0 commit comments