Skip to content

Commit

Permalink
refactor: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rjlopezdev committed Oct 4, 2024
1 parent 764e478 commit 4def79b
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 6 deletions.
7 changes: 6 additions & 1 deletion apps/your-burger-api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CustomerPreferences {}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export abstract class ProposalService {}
export abstract class ProposalService {
abstract computeProposal(preferences: any);
}
6 changes: 5 additions & 1 deletion apps/your-burger-api/src/app/proposal/domain/proposal.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export class Proposal {}
import { Burger } from '../../burger-business/domain/burger';

export class Proposal {
burguers: Burger[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CustomerPreferencesDto {}
Original file line number Diff line number Diff line change
@@ -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: [] };
}
}
2 changes: 2 additions & 0 deletions apps/your-burger-api/src/app/proposal/proposal.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
15 changes: 15 additions & 0 deletions apps/your-burger-api/src/assets/allergens.csv
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions apps/your-burger-api/src/assets/burger-brands.csv
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions apps/your-burger-api/src/assets/ingredients.csv
Original file line number Diff line number Diff line change
@@ -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
Binary file modified apps/your-burger-api/src/assets/your-burger.sqlite3
Binary file not shown.
4 changes: 4 additions & 0 deletions apps/your-burger-api/src/open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

export const API_TAGS = {
BURGERS: 'Burgers',
ALLERGENS: 'Allergens',
INGREDIENTS: 'Ingredients',
BURGER_BRANDS: 'Burger Brands',
BURGER_PLACES: 'Burger Places',
PROPOSAL: 'Proposal',
};

export function setupOpenApi(app: INestApplication) {
Expand Down

0 comments on commit 4def79b

Please sign in to comment.