@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.
- package/.vscode/launch.json +20 -0
- package/CHANGELOG.md +32 -0
- package/coverage/clover.xml +144 -0
- package/coverage/coverage-final.json +11 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/app.ts.html +148 -0
- package/coverage/lcov-report/src/events/publishers/tickets/created.ts.html +106 -0
- package/coverage/lcov-report/src/events/publishers/tickets/index.html +131 -0
- package/coverage/lcov-report/src/events/publishers/tickets/updated.ts.html +106 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/models/index.html +116 -0
- package/coverage/lcov-report/src/models/ticket.ts.html +211 -0
- package/coverage/lcov-report/src/routes/create.ts.html +157 -0
- package/coverage/lcov-report/src/routes/find.ts.html +118 -0
- package/coverage/lcov-report/src/routes/get.ts.html +133 -0
- package/coverage/lcov-report/src/routes/index.html +176 -0
- package/coverage/lcov-report/src/routes/index.ts.html +103 -0
- package/coverage/lcov-report/src/routes/update.ts.html +172 -0
- package/coverage/lcov-report/src/test/index.html +116 -0
- package/coverage/lcov-report/src/test/utils.ts.html +112 -0
- package/coverage/lcov.info +223 -0
- package/package.json +12 -2
- package/pnpm-lock.yaml +50 -19
- package/src/routes/__test__/create.test.ts +2 -1
- package/src/routes/__test__/find.test.ts +1 -1
- package/src/routes/__test__/get.test.ts +1 -1
- package/src/routes/__test__/update.test.ts +7 -6
- package/src/routes/update.ts +1 -1
- package/src/test/utils.ts +0 -9
package/src/routes/update.ts
CHANGED
@@ -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')
|