Skip to content

Commit 59b6f7a

Browse files
committed
Add /api prefix
1 parent 95846a8 commit 59b6f7a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

backend/src/iac/backend-stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class BackendStack extends cdk.Stack {
147147
protocol: elbv2.ApplicationProtocol.HTTP,
148148
targetType: elbv2.TargetType.IP,
149149
healthCheck: {
150-
path: '/health',
150+
path: '/api/health',
151151
interval: cdk.Duration.seconds(30),
152152
timeout: cdk.Duration.seconds(5),
153153
},

backend/src/main.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,33 @@ import { NestFactory } from '@nestjs/core';
22
import { AppModule } from './app.module';
33
import { ConfigService } from '@nestjs/config';
44
import { setupSwagger } from './swagger.config';
5+
import { ValidationPipe } from '@nestjs/common';
6+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
57

68
async function bootstrap() {
79
const app = await NestFactory.create(AppModule);
810
const configService = app.get(ConfigService);
911
const port = configService.get<number>('port') ?? 3000;
1012

13+
// Add global prefix 'api' to all routes
14+
app.setGlobalPrefix('api');
15+
1116
// Setup Swagger
1217
setupSwagger(app);
1318

19+
// Rest of your bootstrap code...
20+
app.useGlobalPipes(new ValidationPipe());
21+
22+
const config = new DocumentBuilder()
23+
.setTitle('Medical Reports API')
24+
.setDescription('API for medical reports application')
25+
.setVersion('1.0')
26+
.addBearerAuth()
27+
.build();
28+
29+
const document = SwaggerModule.createDocument(app, config);
30+
SwaggerModule.setup('docs', app, document);
31+
1432
await app.listen(port);
1533
console.log(`Application is running on: ${await app.getUrl()}`);
1634
}

frontend/src/common/api/reportService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class ReportError extends Error {
2121
*/
2222
export const fetchLatestReports = async (limit = 3): Promise<MedicalReport[]> => {
2323
try {
24-
const response = await axios.get(`${API_URL}/reports/latest?limit=${limit}`);
24+
const response = await axios.get(`${API_URL}/api/reports/latest?limit=${limit}`);
2525
console.log('response', response.data);
2626
console.log('API_URL', API_URL);
2727
return response.data;
@@ -39,7 +39,7 @@ export const fetchLatestReports = async (limit = 3): Promise<MedicalReport[]> =>
3939
*/
4040
export const fetchAllReports = async (): Promise<MedicalReport[]> => {
4141
try {
42-
const response = await axios.get(`${API_URL}/reports`);
42+
const response = await axios.get(`${API_URL}/api/reports`);
4343
return response.data;
4444
} catch (error) {
4545
if (axios.isAxiosError(error)) {
@@ -56,7 +56,7 @@ export const fetchAllReports = async (): Promise<MedicalReport[]> => {
5656
*/
5757
export const markReportAsRead = async (reportId: string): Promise<MedicalReport> => {
5858
try {
59-
const response = await axios.patch(`${API_URL}/reports/${reportId}`, {
59+
const response = await axios.patch(`${API_URL}/api/reports/${reportId}`, {
6060
status: ReportStatus.READ
6161
});
6262

0 commit comments

Comments
 (0)