From 4def79ba605d90389c0ac0dde2d986ceec26cd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Juli=C3=A1n=20L=C3=B3pez=20Ca=C3=B1a?= Date: Fri, 4 Oct 2024 09:15:15 +0200 Subject: [PATCH] refactor: some improvements --- apps/your-burger-api/src/app/app.module.ts | 7 ++- .../http/allergen/allergens.controller.ts | 2 +- .../burger-brand/burger-brand.controller.ts | 2 +- .../http/ingredient/ingredients.controller.ts | 2 +- .../proposal/domain/customer-preferences.ts | 1 + .../app/proposal/domain/proposal.service.ts | 4 +- .../src/app/proposal/domain/proposal.ts | 6 +- .../infra/http/customer-preferences.dto.ts | 1 + .../infra/http/proposal.controller.ts | 17 ++++++ .../src/app/proposal/proposal.module.ts | 2 + apps/your-burger-api/src/assets/allergens.csv | 15 +++++ .../src/assets/burger-brands.csv | 29 +++++++++ .../src/assets/ingredients.csv | 55 ++++++++++++++++++ .../src/assets/your-burger.sqlite3 | Bin 90112 -> 90112 bytes apps/your-burger-api/src/open-api.ts | 4 ++ 15 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 apps/your-burger-api/src/app/proposal/domain/customer-preferences.ts create mode 100644 apps/your-burger-api/src/app/proposal/infra/http/customer-preferences.dto.ts create mode 100644 apps/your-burger-api/src/app/proposal/infra/http/proposal.controller.ts create mode 100644 apps/your-burger-api/src/assets/allergens.csv create mode 100644 apps/your-burger-api/src/assets/burger-brands.csv create mode 100644 apps/your-burger-api/src/assets/ingredients.csv diff --git a/apps/your-burger-api/src/app/app.module.ts b/apps/your-burger-api/src/app/app.module.ts index 36b6d40..6c76a0a 100644 --- a/apps/your-burger-api/src/app/app.module.ts +++ b/apps/your-burger-api/src/app/app.module.ts @@ -2,9 +2,14 @@ import { Module } from '@nestjs/common'; import { BurgerBusinessModule } from './burger-business/burger-business.module'; import { MikroOrmModule } from '@mikro-orm/nestjs'; import config from '../mikro-orm.config'; +import { ProposalModule } from './proposal/proposal.module'; @Module({ - imports: [BurgerBusinessModule, MikroOrmModule.forRoot(config)], + imports: [ + BurgerBusinessModule, + ProposalModule, + MikroOrmModule.forRoot(config), + ], controllers: [], providers: [], }) diff --git a/apps/your-burger-api/src/app/burger-business/infra/http/allergen/allergens.controller.ts b/apps/your-burger-api/src/app/burger-business/infra/http/allergen/allergens.controller.ts index 84a2519..c2e0dce 100644 --- a/apps/your-burger-api/src/app/burger-business/infra/http/allergen/allergens.controller.ts +++ b/apps/your-burger-api/src/app/burger-business/infra/http/allergen/allergens.controller.ts @@ -5,7 +5,7 @@ import { ApiTags } from '@nestjs/swagger'; import { API_TAGS } from '../../../../../open-api'; @Controller('allergens') -@ApiTags(API_TAGS.BURGERS) +@ApiTags(API_TAGS.ALLERGENS) export class AllergensController { constructor(private readonly allergensRepository: AllergensRepository) {} diff --git a/apps/your-burger-api/src/app/burger-business/infra/http/burger-brand/burger-brand.controller.ts b/apps/your-burger-api/src/app/burger-business/infra/http/burger-brand/burger-brand.controller.ts index bcabab1..3c68203 100644 --- a/apps/your-burger-api/src/app/burger-business/infra/http/burger-brand/burger-brand.controller.ts +++ b/apps/your-burger-api/src/app/burger-business/infra/http/burger-brand/burger-brand.controller.ts @@ -5,7 +5,7 @@ import { ApiTags } from '@nestjs/swagger'; import { API_TAGS } from '../../../../../open-api'; @Controller('burger-brands') -@ApiTags(API_TAGS.BURGER_PLACES) +@ApiTags(API_TAGS.BURGER_BRANDS) export class BurgerBrandsController { constructor( private readonly burgerBrandsRepository: BrugerBrandsRepository diff --git a/apps/your-burger-api/src/app/burger-business/infra/http/ingredient/ingredients.controller.ts b/apps/your-burger-api/src/app/burger-business/infra/http/ingredient/ingredients.controller.ts index fe9cf3c..33da8f3 100644 --- a/apps/your-burger-api/src/app/burger-business/infra/http/ingredient/ingredients.controller.ts +++ b/apps/your-burger-api/src/app/burger-business/infra/http/ingredient/ingredients.controller.ts @@ -5,7 +5,7 @@ import { ApiTags } from '@nestjs/swagger'; import { API_TAGS } from '../../../../../open-api'; @Controller('ingredients') -@ApiTags(API_TAGS.BURGERS) +@ApiTags(API_TAGS.INGREDIENTS) export class IngredientsController { constructor(private readonly ingredientsRepository: IngredientsRepository) {} diff --git a/apps/your-burger-api/src/app/proposal/domain/customer-preferences.ts b/apps/your-burger-api/src/app/proposal/domain/customer-preferences.ts new file mode 100644 index 0000000..9154250 --- /dev/null +++ b/apps/your-burger-api/src/app/proposal/domain/customer-preferences.ts @@ -0,0 +1 @@ +export class CustomerPreferences {} diff --git a/apps/your-burger-api/src/app/proposal/domain/proposal.service.ts b/apps/your-burger-api/src/app/proposal/domain/proposal.service.ts index eed7d71..1c0ae97 100644 --- a/apps/your-burger-api/src/app/proposal/domain/proposal.service.ts +++ b/apps/your-burger-api/src/app/proposal/domain/proposal.service.ts @@ -1 +1,3 @@ -export abstract class ProposalService {} +export abstract class ProposalService { + abstract computeProposal(preferences: any); +} diff --git a/apps/your-burger-api/src/app/proposal/domain/proposal.ts b/apps/your-burger-api/src/app/proposal/domain/proposal.ts index fcdd583..972662a 100644 --- a/apps/your-burger-api/src/app/proposal/domain/proposal.ts +++ b/apps/your-burger-api/src/app/proposal/domain/proposal.ts @@ -1 +1,5 @@ -export class Proposal {} +import { Burger } from '../../burger-business/domain/burger'; + +export class Proposal { + burguers: Burger[]; +} diff --git a/apps/your-burger-api/src/app/proposal/infra/http/customer-preferences.dto.ts b/apps/your-burger-api/src/app/proposal/infra/http/customer-preferences.dto.ts new file mode 100644 index 0000000..90cd3ef --- /dev/null +++ b/apps/your-burger-api/src/app/proposal/infra/http/customer-preferences.dto.ts @@ -0,0 +1 @@ +export class CustomerPreferencesDto {} diff --git a/apps/your-burger-api/src/app/proposal/infra/http/proposal.controller.ts b/apps/your-burger-api/src/app/proposal/infra/http/proposal.controller.ts new file mode 100644 index 0000000..3092db9 --- /dev/null +++ b/apps/your-burger-api/src/app/proposal/infra/http/proposal.controller.ts @@ -0,0 +1,17 @@ +import { Controller, Post } from '@nestjs/common'; +import { ApiTags } from '@nestjs/swagger'; +import { Proposal } from '../../domain/proposal'; +import { ProposalService } from '../../domain/proposal.service'; +import { CustomerPreferencesDto } from './customer-preferences.dto'; +import { API_TAGS } from '../../../../open-api'; + +@Controller('proposal') +@ApiTags(API_TAGS.PROPOSAL) +export class ProposalController { + constructor(private readonly proposalService: ProposalService) {} + + @Post() + computeProposal(preferences: CustomerPreferencesDto): Proposal { + return { burguers: [] }; + } +} diff --git a/apps/your-burger-api/src/app/proposal/proposal.module.ts b/apps/your-burger-api/src/app/proposal/proposal.module.ts index af6a89a..4ae34d6 100644 --- a/apps/your-burger-api/src/app/proposal/proposal.module.ts +++ b/apps/your-burger-api/src/app/proposal/proposal.module.ts @@ -1,7 +1,9 @@ import { Module } from '@nestjs/common'; import { ProposalService } from './domain/proposal.service'; +import { ProposalController } from './infra/http/proposal.controller'; @Module({ + controllers: [ProposalController], providers: [{ provide: ProposalService, useClass: ProposalService as any }], }) export class ProposalModule {} diff --git a/apps/your-burger-api/src/assets/allergens.csv b/apps/your-burger-api/src/assets/allergens.csv new file mode 100644 index 0000000..c597838 --- /dev/null +++ b/apps/your-burger-api/src/assets/allergens.csv @@ -0,0 +1,15 @@ +id,name,i18n_key +1,GLUTEN,allergen.gluten +2,CRUSTACEANS,allergen.crustaceans +3,EGGS,allergen.eggs +4,FISH,allergen.fish +5,PEANUTS,allergen.peanuts +6,SOYBEANS,allergen.soybeans +7,MILK,allergen.milk +8,NUTS,allergen.nuts +9,CELERY,allergen.celery +10,MUSTARD,allergen.mustard +11,SESAME,allergen.sesame +12,SULPHUR_DIOXIDE,allergen.sulphurDioxide +13,LUPIN,allergen.lupin +14,MOLLUSCS,allergen.molluscs diff --git a/apps/your-burger-api/src/assets/burger-brands.csv b/apps/your-burger-api/src/assets/burger-brands.csv new file mode 100644 index 0000000..c5953cd --- /dev/null +++ b/apps/your-burger-api/src/assets/burger-brands.csv @@ -0,0 +1,29 @@ +id,name +1,Goiko Grill +2,Mcdonalds +3,Burger King +4,Porn Eat +5,Alfredo's Barbacoa +6,Hamburguesa Nostra +7,Vicio +8,Juancho's BBQ +9,Nugu Burger +10,Beefcius +11,Hundred +12,Lola's Burger +13,Junk Burger +14,Cesar's Burger +15,Frankie Burgers +16,Jenkin's +17,La puerta amarilla +18,La Birra Bar +19,Mad Grill +20,Viva Burger +21,Burmet +22,Briochef +23,Pink's +24,BDPburger +25,Burger Jazz +26,Milwaukee +27,La Bistroteca +28,New York Burger diff --git a/apps/your-burger-api/src/assets/ingredients.csv b/apps/your-burger-api/src/assets/ingredients.csv new file mode 100644 index 0000000..3e02d7d --- /dev/null +++ b/apps/your-burger-api/src/assets/ingredients.csv @@ -0,0 +1,55 @@ +id,name,i18n_key +1,BEEF_PATTY,ingredient.beefPatty +2,CHICKEN_PATTY,ingredient.chickenPatty +3,VEGGIE_PATTY,ingredient.veggiePatty +4,LETTUCE,ingredient.lettuce +5,TOMATO,ingredient.tomato +6,ONION,ingredient.onion +7,PICKLES,ingredient.pickles +8,CHEESE,ingredient.cheese +9,BACON,ingredient.bacon +10,AVOCADO,ingredient.avocado +11,KETCHUP,ingredient.ketchup +12,MUSTARD,ingredient.mustard +13,MAYONNAISE,ingredient.mayonnaise +14,BBQ_SAUCE,ingredient.bbqSauce +15,RELISH,ingredient.relish +16,MUSHROOMS,ingredient.mushrooms +17,JALAPEÑOS,ingredient.jalapeños +18,FRIED_EGG,ingredient.friedEgg +19,CHILI,ingredient.chili +20,SPINACH,ingredient.spinach +21,CUCUMBER,ingredient.cucumber +22,BELL_PEPPER,ingredient.bellPepper +23,OLIVES,ingredient.olives +24,GARLIC,ingredient.garlic +25,PINEAPPLE,ingredient.pineapple +26,SRIRACHA,ingredient.sriracha +27,CHIPOTLE_MAYO,ingredient.chipotleMayo +28,HONEY_MUSTARD,ingredient.honeyMustard +29,RANCH_DRESSING,ingredient.ranchDressing +30,THOUSAND_ISLAND_DRESSING,ingredient.thousandIslandDressing +31,BLUE_CHEESE,ingredient.blueCheese +32,SWISS_CHEESE,ingredient.swissCheese +33,CHEDDAR_CHEESE,ingredient.cheddarCheese +34,MONTEREY_JACK_CHEESE,ingredient.montereyJackCheese +35,AMERICAN_CHEESE,ingredient.americanCheese +36,PROVOLONE_CHEESE,ingredient.provoloneCheese +37,PEPPER_JACK_CHEESE,ingredient.pepperJackCheese +38,BRIOCHE_BUN,ingredient.briocheBun +39,SESAME_BUN,ingredient.sesameBun +40,WHOLE_WHEAT_BUN,ingredient.wholeWheatBun +41,GLUTEN_FREE_BUN,ingredient.gluten-FreeBun +42,BALSAMIC_GLAZE,ingredient.balsamicGlaze +43,TRUFFLE_OIL,ingredient.truffleOil +44,ARUGULA,ingredient.arugula +45,KIMCHI,ingredient.kimchi +46,COLESLAW,ingredient.coleslaw +47,PESTO,ingredient.pesto +48,RED_ONION,ingredient.redOnion +49,CARAMELIZED_ONIONS,ingredient.caramelizedOnions +50,SUN_DRIED_TOMATOES,ingredient.sun-DriedTomatoes +51,GUACAMOLE,ingredient.guacamole +52,BUFFALO_SAUCE,ingredient.buffaloSauce +53,SWEET_CHILI_SAUCE,ingredient.sweetChiliSauce +54,AIOLI,ingredient.aioli diff --git a/apps/your-burger-api/src/assets/your-burger.sqlite3 b/apps/your-burger-api/src/assets/your-burger.sqlite3 index 7e3c0512702efa78f1d726b9521cfd32ff9e437d..6c76d124d3d6f8e15e1c3b48b573b3bdb5a3ffcc 100644 GIT binary patch delta 3895 zcmZ`+U2G#)6~4~coA~eEWOtKn*73&M>^8|}H@n#-?b3GH9ov)GiS02nc9vA4=4N~o z4<66BGoB4u5H3X^1fpUoe-Z_xB6tCT+DL$qKou25s>BNgA)!7XD18En3JG`siF3#K znIt7j6zQJt{NC@JbLW{?LeIPs`a)u;A0adXe|tYe4=&$0)sN=xKOK)xqv604h+M{h z2t4t?em(MuIiY`aVj}SD?DIMNVB~U2pTB9Yu>aF#Ezz8vkM_79=}}yiI;jUL!j@L#c0*n?pfiDzNU_o6N4Q+tjQ(<3tc91G>3s zv%1dAj`K*oPnZZ$!(f0i9egGrECimH$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