Skip to content

Init of the Server and the files - #1

Merged
EmmaFrx merged 7 commits into
mainfrom
topic-server-init
Sep 22, 2025
Merged

EmmaFrx merged 7 commits into
mainfrom
topic-server-init

Conversation

@FukuInTheCode

Copy link
Copy Markdown
Owner

This pull request sets up the foundational backend infrastructure for a .NET web API project, including project configuration, MongoDB context, JWT authentication, and basic controller structure. The changes establish key services and settings required for a secure, database-backed API.

Project and Dependency Setup:

  • Added a new project file Server.csproj targeting .NET 8.0, enabling nullable reference types, and specifying required NuGet packages for web API, MongoDB, and JWT authentication.
  • Added a development launch profile in launchSettings.json for local testing with HTTP and HTTPS endpoints.

Service and Middleware Configuration:

  • Configured controllers to use camelCase JSON serialization, enabled JWT authentication with validation parameters from configuration, and set up MongoDB connection string and JWT settings from configuration in Program.cs. Also configured Kestrel to listen on all interfaces.
  • Added a basic development appsettings.Development.json for logging configuration.

Database and Controller Infrastructure:

  • Introduced a thread-safe, static MongoDBContext class for managing MongoDB client and collections, using a singleton pattern.
  • Created a BaseController class with a helper method for returning 403 Forbidden responses.

@FukuInTheCode FukuInTheCode self-assigned this Sep 16, 2025
@FukuInTheCode FukuInTheCode added the enhancement New feature or request label Sep 16, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR establishes the foundational backend infrastructure for a .NET 8.0 web API project with MongoDB and JWT authentication support. The changes create the basic project structure and configuration needed for a secure, database-backed API.

  • Sets up project dependencies and configuration for MongoDB, JWT authentication, and web API functionality
  • Implements MongoDB context management and JWT authentication middleware
  • Creates base controller infrastructure with helper methods

Reviewed Changes

Copilot reviewed 6 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Server.csproj Project file defining .NET 8.0 target framework and required NuGet packages
appsettings.Development.json Development logging configuration
Properties/launchSettings.json Launch profiles for HTTP/HTTPS development endpoints
Program.cs Application startup configuration with JWT authentication and MongoDB settings
Controllers/BaseController.cs Base controller class with helper method for 403 responses
Contexts/MongoDbContext.cs Static MongoDB context class with thread-safe client initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Server/Server.csproj Resolved
Comment thread Server/Program.cs Resolved
Comment thread Server/Program.cs
Comment on lines +48 to +52
// Add this line to listen on all interfaces
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(5000);
});

Copilot AI Sep 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded port 5000 conflicts with the configured ports in launchSettings.json (5280 for HTTP, 7015 for HTTPS). This could cause confusion during development. Consider using configuration values or removing this if the launch settings are sufficient.

Suggested change
// Add this line to listen on all interfaces
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(5000);
});

Copilot uses AI. Check for mistakes.
return;

Client = new MongoClient(Settings.MongoConnectionString);
Console.WriteLine("Settings.MongoConnectionString: " + Settings.MongoConnectionString);

Copilot AI Sep 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging the MongoDB connection string to console may expose sensitive credentials in logs. Consider removing this debug output or use proper logging with appropriate log levels that can be filtered in production.

Suggested change
Console.WriteLine("Settings.MongoConnectionString: " + Settings.MongoConnectionString);
// Removed logging of MongoDB connection string to avoid exposing sensitive credentials.

Copilot uses AI. Check for mistakes.
@FukuInTheCode FukuInTheCode added this to the PLAN milestone Sep 19, 2025
@EmmaFrx
EmmaFrx merged commit c75aa8c into main Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants