renaming and docs

This commit is contained in:
Anika Raemer 2025-10-04 18:16:49 +02:00
parent b1b714f44e
commit 7e831cfb64
14 changed files with 86 additions and 32 deletions

View file

@ -1,5 +1,5 @@
import { Router } from "express";
import { AuthController } from "../controllers/AuthController.js";
import { AuthHandler } from "../handlers/AuthHandler.js";
import { UserRepository } from "../repositories/UserRepository.js";
import { UserDtoEntityMapper } from "../mappers/UserDtoEntityMapper.js";
import {
@ -14,8 +14,13 @@ export const authBasicRoute = "/auth"
const router = Router();
const userRepository = new UserRepository();
const mapper = new UserDtoEntityMapper();
const authController = new AuthController(userRepository, mapper);
const authController = new AuthHandler(userRepository, mapper);
/**
* Login using username and password
* Consumes LoginRequestDto
* Responds with LoginResponseDto
*/
router.post("/login", async (req, res) => {
console.log("login point called")
try {

View file

@ -1,7 +1,7 @@
import { Router } from "express";
import { asyncHandler } from "../utils/asyncHandler.js";
import { RecipeRepository } from "../repositories/RecipeRepository.js";
import { CompactRecipeController } from "../controllers/CompactRecipeController.js";
import { CompactRecipeHandler } from "../handlers/CompactRecipeHandler.js";
import { CompactRecipeDtoEntityMapper } from "../mappers/CompactRecipeDtoEntityMapper.js";
/**
@ -12,9 +12,10 @@ const router = Router();
// Inject repo + mapper here
const recipeRepository = new RecipeRepository();
const compactRecipeMapper = new CompactRecipeDtoEntityMapper();
const compactRecipeController = new CompactRecipeController(recipeRepository, compactRecipeMapper);
const compactRecipeController = new CompactRecipeHandler(recipeRepository, compactRecipeMapper);
/**
* Load header data of all recipes
* Responds with a list of CompactRecipeDtos
*/
router.get(
"/",

View file

@ -1,7 +1,7 @@
import { Router } from "express";
import { RecipeRepository } from "../repositories/RecipeRepository.js";
import { RecipeDtoEntityMapper } from "../mappers/RecipeDtoEntityMapper.js";
import { RecipeController } from "../controllers/RecipeController.js";
import { RecipeHandler } from "../handlers/RecipeHandler.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import { RecipeDto } from "../dtos/RecipeDto.js";
import { RecipeIngredientDtoEntityMapper } from "../mappers/RecipeIngredientDtoEntityMapper.js";
@ -20,10 +20,12 @@ const recipeIngredientMapper = new RecipeIngredientDtoEntityMapper();
const recipeIngredientGroupMapper = new RecipeIngredientGroupDtoEntityMapper(recipeIngredientMapper);
const recipeInstructionStepMapper = new RecipeInstructionStepDtoEntityMapper();
const recipeMapper = new RecipeDtoEntityMapper(recipeInstructionStepMapper, recipeIngredientGroupMapper);
const recipeController = new RecipeController(recipeRepository, recipeMapper);
const recipeController = new RecipeHandler(recipeRepository, recipeMapper);
/**
* Create new recipe
* Consumes: RecipeDto
* Responds with RecipeDto
*/
router.post(
"/",
@ -34,6 +36,10 @@ router.post(
})
);
/**
* Load recipe by id
* Responds with RecipeDto
*/
router.get(
"/:id",
asyncHandler(async(req, res) => {
@ -43,6 +49,12 @@ router.get(
})
);
/**
* Saves existing recipe
* Also handles changes to instructions steps and ingredient (groups)
* Consumes: RecipeDto
* Responds with RecipeDto
*/
router.put(
"/:id",
asyncHandler(async(req, res) =>{

View file

@ -1,5 +1,5 @@
import { Router } from "express";
import { UserController } from "../controllers/UserController.js";
import { UserHandler } from "../handlers/UserHandler.js";
import { CreateUserRequestDto } from "../dtos/CreateUserRequestDto.js";
import { UserRepository } from "../repositories/UserRepository.js";
import { UserDtoEntityMapper } from "../mappers/UserDtoEntityMapper.js";
@ -13,10 +13,12 @@ const router = Router();
// Inject repo + mapper here
const userRepository = new UserRepository();
const userMapper = new UserDtoEntityMapper();
const userController = new UserController(userRepository, userMapper);
const userController = new UserHandler(userRepository, userMapper);
/**
* Create a new user
* Consumes CreateUserRequestDto
* Responds with UserDto
*/
router.post(
"/",
@ -29,6 +31,7 @@ router.post(
/**
* Get user data for current user
* Responds with UserDto
*/
router.get("/me",
asyncHandler(async (req, res) => {