- You should work in a separate branch.
- All tasks should be implemented in one branch.
- You should push this branch to GitHub and open a Pull Request.
- Do not use any Generative AI.
- Do not share your results with your teammates.
- Creating tests are not needed.
You most probably won't finish all of the tasks. It is totally OK. Try to create the best quality code for the finished tasks.
- Right now if, an unknown command is given as the first argument of our app, it throws an error.
- Handle this error and show only the error's message to the user.
Example command and output:
npm start -- start-engine
Error: Unknown command: start-engine
- Validate the
list
command's arguments. - If it has any show meaningful error message to the user.
Example:
npm start -- list unnecessary
Error: The list command should not have any argument.
- A new
details
command is available. - It should have one argument, the
id
of the recipe. - It should display the recipe details (currently the ID and the name only).
- If the recipe ID is not numeric show a meaningful error message to the user.
Example:
npm start -- details 1
ID: 1
Name: Scrambled Egg
- A new
create
command is available. - The command has one argument, the
name
of the recipe. - If the
name
is missing, the app should show a meaningful error message to the user. - Create a new
CreateRecipeType
from theRecipeType
type.CreateRecipeType
is the same asRecipeType
without theid
property. The new type should reuse theRecipeType
use the typescript utilities. - The app should generate a new unique numeric ID for the recipe.
- If the recipe is created successfully, its details should be displayed
the same way like in the
details
command.
Example:
npm start -- create Oatmeal
ID: 3
Name: Oatmeal
- Extend the recipe properties with a
difficulty
. - The difficulty can only the following strings:
easy
,medium
,hard
. - List the difficulties in the details command.
- Hint: You can update the initial values in the
src/index.ts
then delete thedata.json
.
Example:
npm start -- details 1
ID: 1
Name: Scrambled Egg
Difficulty: easy
- The create command should have a second argument, the difficulty.
- If not
easy
,medium
orhard
given show a meaningful error message to the user.
Example:
npm start -- create "Duck in orange sauce" hard
ID: 2
Name: Duck in orange sauce
Difficulty: hard
- Create a command
update-name
. - It should have two arguments, the
id
of the recipe and thenewName
. - If the ID is not numeric or missing or the new name is missing show a meaningful error message to the user.
- Create a new
UpdateRecipeType
from theRecipeType
type.UpdateRecipeType
is the same as theRecipeType
without theid
, and all other properties are optional. The new type should reuse theRecipeType
use the typescript utilities. - If the recipe with the given ID is not exists it should show a meaningful error message to the user.
- If the update is successful, show the details of the recipe a same way in the details command.
Example:
npm start -- update-name 1 "Pancake with marmalade"
ID: 1
Name: Pancake with marmalade
Difficulty: easy
- Create a
remove
command. - It has only one argument the
id
of the recipe. - If it is not a numeric argument show a meaningful error message to the user.
- If the recipe with the given ID is not exists show a meaningful error message to the user.
- If the deletion is successful, show the details of the deleted recipe to the user.
Example:
npm start -- remove 1
ID: 1
Name: Pancake
Difficulty: easy
- Extend the recipe with a preparationTime property. It describes the preparation time in minutes.
- It should be numeric.
- Add it to the recipe details (everywhere a recipe details should be displayed, like the details, create, update and remove commands)
- Add it to the create command as a 3rd argument. If it is not numeric or missing show a meaningful error message to the user.
- Hint: You can update the initial values in the
src/index.ts
then delete thedata.json
.
Example:
npm start -- create "Duck in orange sauce" hard 120
ID: 3
Name: Duck in orange sauce
Difficulty: hard
Preparation time: 120 mins
- There are two different type of errors. The
AppError
which indicates any issues that should be displayed to the user in a nice way. - And there are a lot of different type of runtime errors, represented by the Javascript's built in
Error
's object. - Differentiate the two errors. If the
AppError
is happened, show it to a nice way to the user, if a runtime error is given, display the full error with all information, e.g. the stacktrace.
- The recipe can have multiple ingredients.
- An ingredient has a
name
,amount
andunit
. - The name should be a string, the amount is a number and the unit can be
g
(gram) orml
(milliliter). - The new command is
add-ingredient
, it should have 4 arguments. - The
id
of the recipe to add the ingredient to, thename
, the ingredientamount
and theunit
. - If any of them is missing or the ID and the amount is not numeric, or the unit is not one of
g
orml
it should show a meaningful error message to the user. - If the ingredient is successfully added show the details of the recipe.
- The ingredients must be visible in the recipe details (create, update, remove, details commands).
An example ingredient:
{
"name": "Marmalade",
"unit": "g",
"amount": 5
}
npm start -- add-ingredient 1 Marmalade 5 g
ID: 1
Name: Pancake
Difficulty: easy
Preparation time: 15 mins
Ingredients:
- 5 g Marmalade