Skip to content

feat: update template#2

Merged
Quentintnrl merged 1 commit intomainfrom
mair-45-update-with-recent-apis-base-repo
Mar 4, 2026
Merged

feat: update template#2
Quentintnrl merged 1 commit intomainfrom
mair-45-update-with-recent-apis-base-repo

Conversation

@Quentintnrl
Copy link
Contributor

No description provided.

@Quentintnrl Quentintnrl self-assigned this Mar 4, 2026
Copilot AI review requested due to automatic review settings March 4, 2026 02:42
@Quentintnrl Quentintnrl added the enhancement New feature or request label Mar 4, 2026
@Quentintnrl Quentintnrl linked an issue Mar 4, 2026 that may be closed by this pull request
@Quentintnrl Quentintnrl merged commit 1be4aa2 into main Mar 4, 2026
2 checks passed
@Quentintnrl Quentintnrl deleted the mair-45-update-with-recent-apis-base-repo branch March 4, 2026 02:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository from a “Hello World” Rust app to an Actix Web API template with health/hello endpoints, JWT middleware scaffolding, Swagger/OpenAPI docs, and Docker-based local dev setup.

Changes:

  • Add Actix Web server with / (POST) and /health (GET) endpoints plus Swagger UI/OpenAPI generation.
  • Introduce JWT auth middleware module and create a library crate layout (src/lib.rs + module tree).
  • Add Docker/Docker Compose development/runtime scaffolding (Liquibase + Postgres + Redis + nginx) and supporting scripts/ignores.

Reviewed changes

Copilot reviewed 19 out of 22 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
src/main.rs New Actix Web server bootstrap + endpoints + OpenAPI/Swagger UI wiring
src/auth_middleware.rs JWT validation middleware (Actix Transform)
src/lib.rs Exposes middleware/database/endpoints modules as a library crate
src/endpoints/mod.rs Placeholder endpoints module
src/database/mod.rs Database module tree scaffolding
src/database/postgresql/mod.rs Postgres submodule scaffolding
src/database/postgresql/queries/mod.rs Placeholder module
src/database/queries/mod.rs Placeholder module
src/database/query_views/mod.rs Placeholder module
src/database/queries_result_views/mod.rs Placeholder module
entrypoint.sh Dev entrypoint using cargo watch
docker-compose.yml Local stack definition (db/redis/liquibase/api/nginx)
development.Dockerfile Dev image for hot-reload workflow
Dockerfile Multi-stage release build image
Cargo.toml Adds web/db/redis/openapi dependencies and renames package
Cargo.lock Dependency lockfile generated for new crate set
.gitignore Ignore .env and Postman collection export
.dockerignore Reduce Docker build context contents
.github/workflows/cicd.yml CI/CD workflow placeholder (currently commented out)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

networks:
- backend
depends_on:
{api}: #change api name
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

nginx.depends_on references {api}, but the service defined in this file is named api. As-is, Compose will error because {api} is not a valid service key. If this is meant to be templated, consider using a valid default (e.g., api) and drive overrides via variables instead of changing YAML keys.

Suggested change
{api}: #change api name
api: #change api name

Copilot uses AI. Check for mistakes.
Comment on lines +20 to 22
# Copie du binaire
COPY --from=builder /usr/src/app/target/release/core_api /app/core-api

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The runtime stage copies /usr/src/app/target/release/core_api, but this crate’s package name is API_Template and no [[bin]] name is defined. The release binary produced by cargo build --release won’t be core_api, so the Docker build will fail at this COPY step. Update the COPY path (or set an explicit binary name in Cargo.toml / cargo build --bin ...).

Copilot uses AI. Check for mistakes.
RUN cargo install cargo-watch

# Définir le répertoire de travail
WORKDIR /usr/src/core
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

WORKDIR is /usr/src/core, but docker-compose.yml’s file sync targets /usr/src/{api}/.... With the current defaults, the dev container won’t see synced sources at the working directory used by cargo watch. Align the container workdir with the compose sync targets (or vice versa) so hot-reload works without manual edits.

Suggested change
WORKDIR /usr/src/core
WORKDIR /usr/src/api

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +4
use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer, Responder};

use API_Template::auth_middleware::JwtMiddleware;

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

There are unused imports here (web and JwtMiddleware), which will trigger unused_imports warnings (and can become hard errors if warnings are denied in CI/tooling). Either remove them for now, or wire the middleware/scope into the App so the imports are used.

Suggested change
use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer, Responder};
use API_Template::auth_middleware::JwtMiddleware;
use actix_web::{get, middleware, post, App, HttpResponse, HttpServer, Responder};

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +22
# name: API CI/CD

# on:
# workflow_dispatch:
# push:

# permissions:
# contents: read
# packages: write

# jobs:
# APIs-cicd:
# uses: mairie360/CICD/.github/workflows/APIs_cicd.yml@main
# permissions:
# contents: write
# packages: write
# id-token: write
# with:
# postman_collection: ${{ vars.POSTMAN_{API}_API_COLLECTION_ID }} #change api name
# postman_environment: ${{ vars.POSTMAN_{API}_API_ENV_ID }} #change api name
# package_name: api-api #change api name
# secrets: inherit
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

This workflow file is fully commented out, so it will never run. After removing the other workflows, the repo effectively has no CI configured; either enable this workflow (and make placeholders valid) or remove it to avoid confusion.

Suggested change
# name: API CI/CD
# on:
# workflow_dispatch:
# push:
# permissions:
# contents: read
# packages: write
# jobs:
# APIs-cicd:
# uses: mairie360/CICD/.github/workflows/APIs_cicd.yml@main
# permissions:
# contents: write
# packages: write
# id-token: write
# with:
# postman_collection: ${{ vars.POSTMAN_{API}_API_COLLECTION_ID }} #change api name
# postman_environment: ${{ vars.POSTMAN_{API}_API_ENV_ID }} #change api name
# package_name: api-api #change api name
# secrets: inherit

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +16
/** * Handles a POST request to the root endpoint.
* Responds with a simple "Hello, world!" message.
*/
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The block doc comment starts as /** * Handles ... which embeds the leading * into the first line and is inconsistent with typical Rust doc comments. Prefer /// line doc comments (or a properly formatted /** ... */) so the generated docs render cleanly.

Copilot uses AI. Check for mistakes.
components(
),
tags(
(name = "Template API", description = "Endpoints for templatefunctionalities")
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

Typo in the OpenAPI tag description: templatefunctionalities should be template functionalities (or similar).

Suggested change
(name = "Template API", description = "Endpoints for templatefunctionalities")
(name = "Template API", description = "Endpoints for template functionalities")

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 12
x-common-env: &common-env
HOSTNAME: "0.0.0.0"
PORT: 3000
HOST: "0.0.0.0"
PORT: {port} #change port
REDIS_URL: redis://redis:6379
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

PORT: {port} is not valid YAML (unquoted {...} is parsed as a flow mapping), so docker compose will fail to parse this file. Use a quoted placeholder or (preferably) Compose env substitution (e.g., ${PORT} with a default) so the file remains valid YAML out of the box.

Copilot uses AI. Check for mistakes.
volumes:
postgres-data:
redis-data:
core-target:
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

Top-level volume is declared as core-target, but the api service mounts api-target. As written, core-target is unused and the intended named volume for the build cache/target dir is unclear. Align the declared volume name with the one mounted by the service.

Suggested change
core-target:
api-target:

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +24
FROM debian:bookworm-slim
WORKDIR /app

# Définir les permissions
RUN chown -R core:core /usr/src/core
USER core
# Installation des certificats CA
RUN apt update && apt install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*

# Définir les variables d'environnement
ENV RUST_BACKTRACE=1
ENV HOSTNAME="0.0.0.0"
ENV PORT=3000
# Copie du binaire
COPY --from=builder /usr/src/app/target/release/core_api /app/core-api

# Exposer le port
EXPOSE 3000

# Commande pour exécuter le projet en mode release
CMD ["cargo", "run", "--release"]
# On lance le binaire
CMD ["./core-api"] No newline at end of file
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

In this runtime image stage, the service runs as the default root user because no USER directive is set, whereas the previous Dockerfile explicitly dropped privileges to a non-root user. If an attacker ever achieves remote code execution in the application, they will gain full root privileges inside the container, which significantly increases the risk of container breakout or host impact. To reduce this risk, create a dedicated unprivileged user in this stage and switch to it with a USER directive before starting core-api.

Copilot uses AI. Check for mistakes.
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.

MAIR-45 update with recent APIs base repo

2 participants