Skip to content

Commit 19f0ecc

Browse files
authored
Merge branch 'main' into fix/mirabel64-ba-088-090-091-096
2 parents 76cc75a + 1fe81ce commit 19f0ecc

309 files changed

Lines changed: 22281 additions & 4705 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.freebuff/project-id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bbf909d9-9053-4c71-9421-63b2bb0139ce

.kilo/kilo.jsonc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://app.kilo.ai/config.json",
3+
"snapshot": false
4+
}

BackendAcademy/.env.example

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,47 @@ PORT=3000
33
NODE_ENV=development
44

55
# Database
6+
# REQUIRED in production. Local/development uses the default below when omitted.
67
DATABASE_URL=postgresql://postgres:password@localhost:5432/rustacademy
78

89
# Redis
10+
# REQUIRED in production. Defaults to localhost in development/test.
911
REDIS_HOST=localhost
1012
REDIS_PORT=6379
1113
REDIS_PASSWORD=
1214

1315
# Auth
16+
# REQUIRED in production with >= 32 chars and NOT a placeholder value.
17+
# Development/test use explicit non-production defaults when omitted.
1418
JWT_SECRET=change_me_in_production
19+
# Maximum allowed clock skew (seconds) tolerated when verifying JWT
20+
# exp/nbf claims. Distributed clocks can drift, causing premature expiry
21+
# or acceptance of expired tokens. Bounded to 0..120 by config validation.
22+
JWT_CLOCK_SKEW_SECONDS=30
23+
24+
# Signing secret for signed asset download URLs.
25+
# REQUIRED in production; an empty value makes signed URLs forgeable.
26+
ASSET_SIGNING_SECRET=change_me_in_production
1527

1628
# API Keys
1729
API_KEY_SECRET=change_me_in_production
1830

1931
# CORS
32+
# "*" or a comma-separated list of origins.
2033
CORS_ORIGIN=http://localhost:3000
2134

2235
# AI Provider
2336
AI_PROVIDER=mock # claude | openai | mock
24-
ANTHROPIC_API_KEY= # Your Anthropic API key
25-
OPENAI_API_KEY= # Your OpenAI API key
26-
AI_MODEL= # Model override (optional)
37+
ANTHROPIC_API_KEY= # Required when AI_PROVIDER=claude
38+
OPENAI_API_KEY= # Required when AI_PROVIDER=openai
39+
AI_MODEL= # Model override (optional)
2740
AI_MAX_TOKENS=4096
2841
AI_TEMPERATURE=0.7
2942

3043
# Static & uploaded assets
3144
ASSETS_UPLOAD_DIR=./data/uploads # Where uploaded assets are persisted on disk
32-
ASSETS_MAX_SIZE_MB=10 # Max upload size in megabytes
45+
ASSETS_MAX_SIZE_MB=10 # Per-file upload size limit in megabytes
46+
ASSETS_MAX_TOTAL_MB=1024 # Aggregate byte quota across all stored assets (MB)
47+
ASSETS_MAX_COUNT=10000 # Maximum number of assets retained by the registry
3348
ASSETS_BASE_URL=/api/v1/assets # Base URL advertised inside asset metadata
3449
ASSETS_STATIC_DIR=./public # Read-only static asset directory served at /static

BackendAcademy/BackendAcademy/src/courses/courses.module.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ import { Module } from '@nestjs/common';
22
import { CoursesController } from './courses.controller';
33
import { CoursesService } from './courses.service';
44

5+
/**
6+
* CoursesModule
7+
*
8+
* Groups together everything related to the "courses" feature:
9+
* the controller (handles HTTP requests) and the service (business logic).
10+
*/
511
@Module({
12+
// Controllers that belong to this module and handle incoming requests
613
controllers: [CoursesController],
14+
15+
// Providers (services) available for dependency injection within this module
716
providers: [CoursesService],
17+
18+
// Providers exported so other modules can import and use CoursesService
819
exports: [CoursesService],
920
})
10-
export class CoursesModule {}
21+
export class CoursesModule {}

BackendAcademy/BackendAcademy/src/courses/courses.service.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { NotFoundException } from '@nestjs/common';
33
import { CoursesService } from './courses.service';
44

55
describe('CoursesService', () => {
6+
// Holds the instance of the service under test
67
let service: CoursesService;
78

9+
// Runs before each test: builds a fresh testing module and resolves the service
810
beforeEach(async () => {
911
const module: TestingModule = await Test.createTestingModule({
1012
providers: [CoursesService],
@@ -13,21 +15,32 @@ describe('CoursesService', () => {
1315
service = module.get<CoursesService>(CoursesService);
1416
});
1517

18+
// Sanity check: the service should be instantiated correctly by the DI container
1619
it('should be defined', () => {
1720
expect(service).toBeDefined();
1821
});
1922

23+
// create() should return the submitted data merged with a generated id
2024
it('create() returns the dto with an id', () => {
21-
const result = service.create({ title: 'Rust Basics', description: 'An intro to Rust programming language.' });
25+
const result = service.create({
26+
title: 'Rust Basics',
27+
description: 'An intro to Rust programming language.',
28+
});
29+
30+
// The returned object should contain the same title we passed in
2231
expect(result).toMatchObject({ title: 'Rust Basics' });
32+
33+
// An id should have been generated for the new course
2334
expect(result.id).toBeDefined();
2435
});
2536

37+
// findAll() should always return an array (even if empty)
2638
it('findAll() returns an array', () => {
2739
expect(Array.isArray(service.findAll())).toBe(true);
2840
});
2941

42+
// findOne() should throw a NotFoundException when the course doesn't exist
3043
it('findOne() throws NotFoundException for unknown id', () => {
3144
expect(() => service.findOne(999)).toThrow(NotFoundException);
3245
});
33-
});
46+
});

BackendAcademy/BackendAcademy/src/courses/courses.service.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,68 @@ import { Injectable, NotFoundException } from '@nestjs/common';
22
import { CreateCourseDto } from './dto/create-course.dto';
33
import { UpdateCourseDto } from './dto/update-course.dto';
44

5+
/**
6+
* CoursesService
7+
*
8+
* Contains the business logic for managing courses (CRUD operations).
9+
* Currently uses stub/placeholder logic; real persistence (e.g. via a
10+
* repository or ORM) still needs to be implemented.
11+
*/
512
@Injectable()
613
export class CoursesService {
14+
/**
15+
* Creates a new course.
16+
* TODO: persist the course via a repository instead of just returning it.
17+
*/
718
create(dto: CreateCourseDto) {
819
// TODO: persist via repository
20+
// Temporary: fake an id using the current timestamp
921
return { ...dto, id: Date.now() };
1022
}
1123

24+
/**
25+
* Retrieves all courses.
26+
* TODO: fetch the list from a repository/database.
27+
*/
1228
findAll() {
1329
// TODO: query repository
30+
// Temporary: no data source yet, so return an empty array
1431
return [];
1532
}
1633

34+
/**
35+
* Retrieves a single course by id.
36+
* TODO: fetch the course from a repository/database.
37+
* Throws a NotFoundException if the course doesn't exist.
38+
*/
1739
findOne(id: number) {
1840
// TODO: query repository
41+
// Temporary: no data source yet, so this is always null
1942
const course = null;
43+
44+
// Guard clause: bail out with a 404-style error if nothing was found
2045
if (!course) throw new NotFoundException(`Course #${id} not found`);
46+
2147
return course;
2248
}
2349

50+
/**
51+
* Updates an existing course by id.
52+
* TODO: look up the existing course, then persist the merged changes.
53+
*/
2454
update(id: number, dto: UpdateCourseDto) {
2555
// TODO: query then persist
56+
// Temporary: just echo back the id and updated fields
2657
return { id, ...dto };
2758
}
2859

60+
/**
61+
* Removes a course by id.
62+
* TODO: actually delete the record from the repository/database.
63+
*/
2964
remove(id: number) {
3065
// TODO: delete from repository
66+
// Temporary: just acknowledge the deletion request
3167
return { deleted: id };
3268
}
33-
}
69+
}

0 commit comments

Comments
 (0)