Skip to content

Commit

Permalink
usando el cerebro
Browse files Browse the repository at this point in the history
  • Loading branch information
tfloxolodeiro committed Nov 28, 2023
1 parent 30b4455 commit a348590
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/api/routes/creatorChallenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ const router = express.Router()
router.post('/share', tryy(tokenAuth), onlyIfAuth, syncHandler(async (req: AuthenticatedRequest, res) => {
const { user, body } = req
body.user = user

const shareId = body.shareId || undefined //The findOne breaks if the id is empty string.
const posibleExistingChallenge : CreatorChallenge | undefined = await CreatorChallengeModel.findOne({_id: shareId, user: user._id})
res.json(posibleExistingChallenge || await CreatorChallengeModel.create({...body}))

res.json(await CreatorChallengeModel.create({...body}))
}))

router.get('/sharedChallenge/:_id', (async (req: AuthenticatedRequest, res) => {
Expand Down

0 comments on commit a348590

Please sign in to comment.