File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff 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 } ,
Original file line number Diff line number Diff line change @@ -2,15 +2,33 @@ import { NestFactory } from '@nestjs/core';
22import { AppModule } from './app.module' ;
33import { ConfigService } from '@nestjs/config' ;
44import { setupSwagger } from './swagger.config' ;
5+ import { ValidationPipe } from '@nestjs/common' ;
6+ import { DocumentBuilder , SwaggerModule } from '@nestjs/swagger' ;
57
68async 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}
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export class ReportError extends Error {
2121 */
2222export 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 */
4040export 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 */
5757export 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
You can’t perform that action at this time.
0 commit comments