Skip to content

Commit

Permalink
remove userid from create endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
eyvmal committed Oct 30, 2024
1 parent ec82dc9 commit 562d882
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 16 additions & 6 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,21 @@ paths:
properties:
content:
type: string
userid:
type: integer
responses:
201:
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/Post'
400:
description: fail
401:
description: Unauthorised
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
Expand All @@ -222,7 +226,13 @@ paths:
schema:
$ref: '#/components/schemas/Posts'
'401':
description: fail
description: Unauthorised
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal server error
content:
application/json:
schema:
Expand Down Expand Up @@ -616,7 +626,7 @@ components:
format: date-time
profileImageUrl:
type: string

UpdatePost:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Post from '../domain/post.js'
import User from '../domain/user.js'

export const create = async (req, res) => {
const { content, userid } = req.body
const user = await User.findById(userid)
const { content } = req.body
const user = await User.findById(req.user.id)

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

0 comments on commit 562d882

Please sign in to comment.