File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ This project is a boilerplate for building .NET API applications with various fe
66
77## Features
88
9+ - [x] Swagger
910- [x] Authentication using JWT Bearer tokens
1011- [x] Rate limiting to prevent API abuse
1112- [x] CORS policies for secure cross-origin requests
Original file line number Diff line number Diff line change 2020
2121var builder = WebApplication . CreateBuilder ( args ) ;
2222
23+ var IsDevelopment = builder . Environment . IsDevelopment ( ) ;
2324
2425// ✅ Ensure correct access to configuration
2526var configuration = builder . Configuration ;
153154 options . JsonSerializerOptions . ReferenceHandler = ReferenceHandler . Preserve ;
154155 } ) ;
155156
156- builder . Services . AddEndpointsApiExplorer ( ) ;
157- builder . Services . AddSwaggerGen ( ) ;
157+ if ( IsDevelopment )
158+ {
159+ builder . Services . AddEndpointsApiExplorer ( ) ;
160+ builder . Services . AddSwaggerGen ( ) ;
161+ }
158162
159163// Enable Compression to reduce payload size
160164builder . Services . AddResponseCompression ( options =>
171175
172176// Console.WriteLine(app.Environment.IsDevelopment().ToString());
173177Console . WriteLine ( $ "Running in { builder . Environment . EnvironmentName } mode") ;
178+ // Console.WriteLine($"Running in Dev={isDev} mode");
174179
175180// -----------------------------------------------------------------------------------------
176181// Apply Authentication Middleware
177182
178- app . UseAuthentication ( ) ;
183+ app . UseAuthentication ( ) ;
179184app . UseAuthorization ( ) ;
180185
181186// -----------------------------------------------------------------------------------------
182187
183- var IsDevelopment = app . Environment . IsDevelopment ( ) ;
188+ // var IsDevelopment = app.Environment.IsDevelopment();
184189
185190if ( IsDevelopment )
186191{
Original file line number Diff line number Diff line change 2626 ]
2727 },
2828 "ConnectionStrings" : {
29- "DefaultConnection" : " Data Source=expensemanager .db;Pooling=True;"
29+ "DefaultConnection" : " Data Source=yourlocalldb .db;Pooling=True;"
3030 }
3131}
You can’t perform that action at this time.
0 commit comments