@next-k8s/tickets 1.0.17 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/.vscode/launch.json +20 -0
  2. package/CHANGELOG.md +32 -0
  3. package/coverage/clover.xml +144 -0
  4. package/coverage/coverage-final.json +11 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +176 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov-report/src/app.ts.html +148 -0
  14. package/coverage/lcov-report/src/events/publishers/tickets/created.ts.html +106 -0
  15. package/coverage/lcov-report/src/events/publishers/tickets/index.html +131 -0
  16. package/coverage/lcov-report/src/events/publishers/tickets/updated.ts.html +106 -0
  17. package/coverage/lcov-report/src/index.html +116 -0
  18. package/coverage/lcov-report/src/models/index.html +116 -0
  19. package/coverage/lcov-report/src/models/ticket.ts.html +211 -0
  20. package/coverage/lcov-report/src/routes/create.ts.html +157 -0
  21. package/coverage/lcov-report/src/routes/find.ts.html +118 -0
  22. package/coverage/lcov-report/src/routes/get.ts.html +133 -0
  23. package/coverage/lcov-report/src/routes/index.html +176 -0
  24. package/coverage/lcov-report/src/routes/index.ts.html +103 -0
  25. package/coverage/lcov-report/src/routes/update.ts.html +172 -0
  26. package/coverage/lcov-report/src/test/index.html +116 -0
  27. package/coverage/lcov-report/src/test/utils.ts.html +112 -0
  28. package/coverage/lcov.info +223 -0
  29. package/package.json +12 -2
  30. package/pnpm-lock.yaml +50 -19
  31. package/src/routes/__test__/create.test.ts +2 -1
  32. package/src/routes/__test__/find.test.ts +1 -1
  33. package/src/routes/__test__/get.test.ts +1 -1
  34. package/src/routes/__test__/update.test.ts +7 -6
  35. package/src/routes/update.ts +1 -1
  36. package/src/test/utils.ts +0 -9
@@ -18,7 +18,7 @@ router.put('/api/tickets/:id', requireAuth, validateInput, validateRequest, asyn
18
18
  if (!isValidObjectId(req.params.id)) throw new BadRequestError('Invalid Ticket ID')
19
19
  const ticket = await Ticket.findById(req.params.id)
20
20
  if (!ticket) throw new NotFoundError()
21
- if (ticket.owner !== req.currentUser!.id) throw new UnauthorizedError()
21
+ if (ticket.owner.toHexString() !== req.currentUser!.id) throw new UnauthorizedError()
22
22
  const { title, price } = req.body
23
23
  ticket.set({ title, price })
24
24
  await ticket.save()
package/src/test/utils.ts CHANGED
@@ -1,14 +1,5 @@
1
- import jwt from 'jsonwebtoken'
2
- import mongoose from 'mongoose'
3
1
  import request from 'supertest'
4
2
 
5
- export const getTokenCookie = async () => {
6
- const payload = { id: new mongoose.Types.ObjectId().toHexString(), email: 'test@test.com' }
7
- const token = jwt.sign(payload, process.env.JWT_KEY!)
8
- const cookie = Buffer.from(JSON.stringify({ jwt: token })).toString('base64')
9
- return `session=${cookie}`
10
- }
11
-
12
3
  export const createTicket = (app: Express.Application, cookie?: string, title = 'Test Event', price = 20000, expectedStatusCode = 201) => {
13
4
  return request(app)
14
5
  .post('/api/tickets')