Skip to content

Commit ee0191e

Browse files
author
eyvmal
committed
remove userid from create endpoint
1 parent 8761235 commit ee0191e

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

docs/openapi.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,21 @@ paths:
191191
properties:
192192
content:
193193
type: string
194-
userid:
195-
type: integer
196194
responses:
197195
201:
198196
description: success
199197
content:
200198
application/json:
201199
schema:
202200
$ref: '#/components/schemas/Post'
203-
400:
204-
description: fail
201+
401:
202+
description: Unauthorised
203+
content:
204+
application/json:
205+
schema:
206+
$ref: '#/components/schemas/Error'
207+
'500':
208+
description: Internal server error
205209
content:
206210
application/json:
207211
schema:
@@ -222,7 +226,13 @@ paths:
222226
schema:
223227
$ref: '#/components/schemas/Posts'
224228
'401':
225-
description: fail
229+
description: Unauthorised
230+
content:
231+
application/json:
232+
schema:
233+
$ref: '#/components/schemas/Error'
234+
'500':
235+
description: Internal server error
226236
content:
227237
application/json:
228238
schema:

src/controllers/post.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import Post from '../domain/post.js'
33
import User from '../domain/user.js'
44

55
export const create = async (req, res) => {
6-
const { content, userid } = req.body
7-
const user = await User.findById(userid)
6+
const { content } = req.body
7+
const user = await User.findById(req.user.id)
88

99
if (!content) {
1010
return sendDataResponse(res, 400, { content: 'Must provide content' })

0 commit comments

Comments
 (0)