@next-k8s/tickets 1.0.13 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,38 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.0.17](https://github.com/mathiscode/next-k8s-boilerplate/compare/@next-k8s/tickets@1.0.16...@next-k8s/tickets@1.0.17) (2022-07-07)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @next-k8s/tickets
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.0.16](https://github.com/mathiscode/next-k8s-boilerplate/compare/@next-k8s/tickets@1.0.15...@next-k8s/tickets@1.0.16) (2022-07-07)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @next-k8s/tickets
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [1.0.15](https://github.com/mathiscode/next-k8s-boilerplate/compare/@next-k8s/tickets@1.0.14...@next-k8s/tickets@1.0.15) (2022-07-07)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @next-k8s/tickets
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
## [1.0.14](https://github.com/mathiscode/next-k8s-boilerplate/compare/@next-k8s/tickets@1.0.13...@next-k8s/tickets@1.0.14) (2022-07-07)
|
31
|
+
|
32
|
+
**Note:** Version bump only for package @next-k8s/tickets
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
6
38
|
## [1.0.13](https://github.com/mathiscode/next-k8s-boilerplate/compare/@next-k8s/tickets@1.0.12...@next-k8s/tickets@1.0.13) (2022-07-07)
|
7
39
|
|
8
40
|
**Note:** Version bump only for package @next-k8s/tickets
|
package/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Jay Mathis <code@mathis.network>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@next-k8s/tickets",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.17",
|
4
4
|
"main": "index.js",
|
5
5
|
"license": "MIT",
|
6
6
|
"scripts": {
|
@@ -25,7 +25,7 @@
|
|
25
25
|
]
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
|
-
"@next-k8s/common": "^0.1.
|
28
|
+
"@next-k8s/common": "^0.1.30",
|
29
29
|
"@types/cookie-session": "^2.0.44",
|
30
30
|
"@types/express": "^4.17.13",
|
31
31
|
"@types/jsonwebtoken": "^8.5.8",
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"supertest": "^6.2.3",
|
52
52
|
"ts-jest": "^28.0.4"
|
53
53
|
},
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "462d06be86cf3ff8bd1625c310409762cb400c79"
|
55
55
|
}
|
@@ -17,7 +17,7 @@ describe('[Create New Ticket] Route: /api/tickets', () => {
|
|
17
17
|
})
|
18
18
|
|
19
19
|
it('should not get UnauthorizedError if authenticated', async () => {
|
20
|
-
const cookie = await getTokenCookie()
|
20
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
21
21
|
const response = await request(app)
|
22
22
|
.post('/api/tickets')
|
23
23
|
.set('Cookie', [cookie])
|
@@ -27,7 +27,7 @@ describe('[Create New Ticket] Route: /api/tickets', () => {
|
|
27
27
|
})
|
28
28
|
|
29
29
|
it('should throw error if new ticket has invalid title', async () => {
|
30
|
-
const cookie = await getTokenCookie()
|
30
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
31
31
|
await request(app)
|
32
32
|
.post('/api/tickets')
|
33
33
|
.set('Cookie', [cookie])
|
@@ -36,7 +36,7 @@ describe('[Create New Ticket] Route: /api/tickets', () => {
|
|
36
36
|
})
|
37
37
|
|
38
38
|
it('should throw error if new ticket has invalid price', async () => {
|
39
|
-
const cookie = await getTokenCookie()
|
39
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
40
40
|
await request(app)
|
41
41
|
.post('/api/tickets')
|
42
42
|
.set('Cookie', [cookie])
|
@@ -52,7 +52,7 @@ describe('[Create New Ticket] Route: /api/tickets', () => {
|
|
52
52
|
|
53
53
|
it('should create a new ticket', async () => {
|
54
54
|
let tickets = await Ticket.find({})
|
55
|
-
const cookie = await getTokenCookie()
|
55
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
56
56
|
|
57
57
|
await request(app)
|
58
58
|
.post('/api/tickets')
|
@@ -69,7 +69,7 @@ describe('[Create New Ticket] Route: /api/tickets', () => {
|
|
69
69
|
})
|
70
70
|
|
71
71
|
it('should publish a ticket:created event', async () => {
|
72
|
-
const cookie = await getTokenCookie()
|
72
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
73
73
|
await createTicket(app, cookie)
|
74
74
|
expect(natsClient.client.publish).toHaveBeenCalled()
|
75
75
|
})
|
@@ -1,10 +1,14 @@
|
|
1
|
+
|
2
|
+
import mongoose from 'mongoose'
|
1
3
|
import request from 'supertest'
|
4
|
+
import { getTokenCookie } from '@next-k8s/common'
|
5
|
+
|
2
6
|
import app from '../../app'
|
3
|
-
import { createTicket
|
7
|
+
import { createTicket } from '../../test/utils'
|
4
8
|
|
5
9
|
describe('[List Tickets] Route: /api/tickets', () => {
|
6
10
|
it('should return a list of tickets', async () => {
|
7
|
-
const cookie = await getTokenCookie()
|
11
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
8
12
|
await createTicket(app, cookie)
|
9
13
|
await createTicket(app, cookie, 'Test Event 2', 40000)
|
10
14
|
const list = await request(app)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import request from 'supertest'
|
2
2
|
import mongoose from 'mongoose'
|
3
|
+
import { getTokenCookie } from '@next-k8s/common'
|
4
|
+
|
3
5
|
import app from '../../app'
|
4
|
-
import { createTicket
|
6
|
+
import { createTicket } from '../../test/utils'
|
5
7
|
|
6
8
|
describe('[Get Ticket] Route: /api/tickets/:id', () => {
|
7
9
|
it('should throw a BadRequestError if ticket ID is invalid', async () => {
|
@@ -20,7 +22,7 @@ describe('[Get Ticket] Route: /api/tickets/:id', () => {
|
|
20
22
|
})
|
21
23
|
|
22
24
|
it('should return the fetched ticket', async () => {
|
23
|
-
const cookie = await getTokenCookie()
|
25
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
24
26
|
const response = await createTicket(app, cookie)
|
25
27
|
|
26
28
|
const ticket = await request(app)
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import request from 'supertest'
|
2
2
|
import mongoose from 'mongoose'
|
3
|
+
import { getTokenCookie } from '@next-k8s/common'
|
3
4
|
|
4
5
|
import app from '../../app'
|
5
|
-
import { createTicket
|
6
|
+
import { createTicket } from '../../test/utils'
|
6
7
|
import natsClient from '../../nats-client'
|
7
8
|
|
8
9
|
describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
9
10
|
it('should throw a NotFoundError if the ticket does not exist', async () => {
|
10
11
|
const id = new mongoose.Types.ObjectId().toHexString()
|
11
|
-
const cookie = await getTokenCookie()
|
12
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
12
13
|
|
13
14
|
await request(app)
|
14
15
|
.put(`/api/tickets/${id}`)
|
@@ -18,7 +19,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
18
19
|
})
|
19
20
|
|
20
21
|
it('should throw an UnauthorizedError if not authenticated', async () => {
|
21
|
-
const cookie = await getTokenCookie()
|
22
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
22
23
|
|
23
24
|
const response = await request(app)
|
24
25
|
.post(`/api/tickets`)
|
@@ -33,7 +34,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
33
34
|
})
|
34
35
|
|
35
36
|
it('should throw an UnauthorizedError if user does not own the ticket', async () => {
|
36
|
-
const cookie = await getTokenCookie()
|
37
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
37
38
|
|
38
39
|
const response = await request(app)
|
39
40
|
.post(`/api/tickets`)
|
@@ -41,7 +42,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
41
42
|
.send({ title: 'Test Event', price: 20000 })
|
42
43
|
.expect(201)
|
43
44
|
|
44
|
-
const newCookie = await getTokenCookie()
|
45
|
+
const newCookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
45
46
|
|
46
47
|
await request(app)
|
47
48
|
.put(`/api/tickets/${response.body.ticket.id}`)
|
@@ -51,7 +52,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
51
52
|
})
|
52
53
|
|
53
54
|
it('should throw a BadRequestError if an invalid ticket is provided', async () => {
|
54
|
-
const cookie = await getTokenCookie()
|
55
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
55
56
|
|
56
57
|
await request(app)
|
57
58
|
.put(`/api/tickets/notarealid`)
|
@@ -61,7 +62,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
61
62
|
})
|
62
63
|
|
63
64
|
it('should throw an error on invalid ticket data', async () => {
|
64
|
-
const cookie = await getTokenCookie()
|
65
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
65
66
|
const response = await createTicket(app, cookie)
|
66
67
|
|
67
68
|
await request(app)
|
@@ -78,7 +79,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
78
79
|
})
|
79
80
|
|
80
81
|
it('should update a ticket', async () => {
|
81
|
-
const cookie = await getTokenCookie()
|
82
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
82
83
|
const response = await createTicket(app, cookie)
|
83
84
|
|
84
85
|
const updated = await request(app)
|
@@ -94,7 +95,7 @@ describe('[Update Ticket] Route: /api/tickets/:id', () => {
|
|
94
95
|
})
|
95
96
|
|
96
97
|
it('should publish a ticket:updated event', async () => {
|
97
|
-
const cookie = await getTokenCookie()
|
98
|
+
const cookie = await getTokenCookie({ id: new mongoose.Types.ObjectId().toHexString() })
|
98
99
|
await createTicket(app, cookie)
|
99
100
|
expect(natsClient.client.publish).toHaveBeenCalled()
|
100
101
|
})
|