Skip to content

Commit d03ce0e

Browse files
committed
feat: rename endpoints plural
1 parent 5b9831c commit d03ce0e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

__tests__/private.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,22 +1439,22 @@ describe('POST /p/newOpportunity', () => {
14391439
});
14401440
});
14411441

1442-
describe('POST /p/opportunity', () => {
1442+
describe('POST /p/opportunities', () => {
14431443
beforeEach(() => {
14441444
jest.clearAllMocks();
14451445
});
14461446

14471447
it('should return 404 without service auth', async () => {
14481448
const res = await request(app.server)
1449-
.post('/p/opportunity')
1449+
.post('/p/opportunities')
14501450
.send({ url: 'https://example.com/job.pdf' });
14511451

14521452
expect(res.statusCode).toBe(404);
14531453
});
14541454

14551455
it('should return 400 for invalid URL', async () => {
14561456
const res = await request(app.server)
1457-
.post('/p/opportunity')
1457+
.post('/p/opportunities')
14581458
.set('authorization', `Service ${process.env.ACCESS_SECRET}`)
14591459
.set('content-type', 'application/json')
14601460
.send({ url: 'not-a-url' });
@@ -1464,7 +1464,7 @@ describe('POST /p/opportunity', () => {
14641464

14651465
it('should return 400 for invalid email', async () => {
14661466
const res = await request(app.server)
1467-
.post('/p/opportunity')
1467+
.post('/p/opportunities')
14681468
.set('authorization', `Service ${process.env.ACCESS_SECRET}`)
14691469
.set('content-type', 'application/json')
14701470
.send({ url: 'https://example.com/job.pdf', emails: ['not-an-email'] });
@@ -1486,7 +1486,7 @@ describe('POST /p/opportunity', () => {
14861486
jest.mocked(triggerTypedEvent).mockResolvedValue(undefined);
14871487

14881488
const res = await request(app.server)
1489-
.post('/p/opportunity')
1489+
.post('/p/opportunities')
14901490
.set('authorization', `Service ${process.env.ACCESS_SECRET}`)
14911491
.set('content-type', 'application/json')
14921492
.send({ url: 'https://example.com/job.pdf' });
@@ -1524,7 +1524,7 @@ describe('POST /p/opportunity', () => {
15241524

15251525
const emails = ['user1@example.com', 'user2@example.com'];
15261526
const res = await request(app.server)
1527-
.post('/p/opportunity')
1527+
.post('/p/opportunities')
15281528
.set('authorization', `Service ${process.env.ACCESS_SECRET}`)
15291529
.set('content-type', 'application/json')
15301530
.send({ url: 'https://example.com/job.pdf', emails });
@@ -1555,7 +1555,7 @@ describe('POST /p/opportunity', () => {
15551555
.mockRejectedValue(new ValidationError('File type not supported'));
15561556

15571557
const res = await request(app.server)
1558-
.post('/p/opportunity')
1558+
.post('/p/opportunities')
15591559
.set('authorization', `Service ${process.env.ACCESS_SECRET}`)
15601560
.set('content-type', 'application/json')
15611561
.send({ url: 'https://example.com/job.pdf' });
@@ -1565,7 +1565,7 @@ describe('POST /p/opportunity', () => {
15651565
});
15661566
});
15671567

1568-
describe('GET /p/opportunity/:id', () => {
1568+
describe('GET /p/opportunities/:id', () => {
15691569
let testOpportunity: OpportunityJob;
15701570

15711571
beforeEach(async () => {
@@ -1586,15 +1586,15 @@ describe('GET /p/opportunity/:id', () => {
15861586

15871587
it('should return 404 without service auth', async () => {
15881588
const res = await request(app.server).get(
1589-
`/p/opportunity/${testOpportunity.id}`,
1589+
`/p/opportunities/${testOpportunity.id}`,
15901590
);
15911591

15921592
expect(res.statusCode).toBe(404);
15931593
});
15941594

15951595
it('should return 400 for invalid UUID', async () => {
15961596
const res = await request(app.server)
1597-
.get('/p/opportunity/not-a-uuid')
1597+
.get('/p/opportunities/not-a-uuid')
15981598
.set('authorization', `Service ${process.env.ACCESS_SECRET}`);
15991599

16001600
expect(res.statusCode).toBe(400);
@@ -1603,7 +1603,7 @@ describe('GET /p/opportunity/:id', () => {
16031603

16041604
it('should return opportunity', async () => {
16051605
const res = await request(app.server)
1606-
.get(`/p/opportunity/${testOpportunity.id}`)
1606+
.get(`/p/opportunities/${testOpportunity.id}`)
16071607
.set('authorization', `Service ${process.env.ACCESS_SECRET}`);
16081608

16091609
expect(res.statusCode).toBe(200);
@@ -1614,7 +1614,7 @@ describe('GET /p/opportunity/:id', () => {
16141614

16151615
it('should return 404 for non-existent opportunity', async () => {
16161616
const res = await request(app.server)
1617-
.get('/p/opportunity/00000000-0000-0000-0000-000000000000')
1617+
.get('/p/opportunities/00000000-0000-0000-0000-000000000000')
16181618
.set('authorization', `Service ${process.env.ACCESS_SECRET}`);
16191619

16201620
expect(res.statusCode).toBe(404);

src/routes/private.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export default async function (fastify: FastifyInstance): Promise<void> {
312312

313313
fastify.post<{
314314
Body: z.infer<typeof privateCreateOpportunitySchema>;
315-
}>('/opportunity', async (req, res) => {
315+
}>('/opportunities', async (req, res) => {
316316
if (!req.service) {
317317
return res.status(404).send();
318318
}
@@ -392,7 +392,7 @@ export default async function (fastify: FastifyInstance): Promise<void> {
392392
});
393393

394394
fastify.get<{ Params: { id: string } }>(
395-
'/opportunity/:id',
395+
'/opportunities/:id',
396396
async (req, res) => {
397397
if (!req.service) {
398398
return res.status(404).send();

0 commit comments

Comments
 (0)