We are looking for production Quality Code.
-
You can use any Framework(expressjs, Fastify, Koa, nestjs, etc.).
-
You can use any libraries you want.
-
Unless explicily specified in API description use the Standard
HTTP Status Codeas per theHTTP Methodyou are using and what type of response you are returning
You have to build 6 APIs for this challenge.
Schema Definations are as Follow
- User
{
"firstName": String,
"lastName": String,
"email": String,
"mobile": Number,
"password": String,
"salt": String
}- Pizza
{
"name": String,
"price": Number,
"ingredients": [String]
}- Order
{
"user": ObjectId,
"pizza": ObjectId,
"orderDate": Date,
"isFulfilled": Boolean
}Description of each API is given below.
- SignUp User (POST
/api/signup) (PUBLIC)
Request Body for this API is as follow:
{
"firstName": String,
"lastName": String,
"email": String,
"mobile": Number,
"password": String,
"confirmPassword": String
}All the fields in User Schema are required. Use Hash & Salt to store
password. It should return the User object without password field in response. Response Body is as follow:
{
"firstName": String,
"lastName": String,
"email": String,
"mobile": Number
}- User Login (POST
/api/login) (PUBLIC)
Request Body for this API is as follow:
{
"email": String,
"password": String
}email & password should be used to login. It should return an object with
accessTokenin it. Response HTTP Status Code should be200. Response Body is as follow:
{
"accessToken": String
}- Insert Pizza Details (POST
/api/pizzas) (SECURED)
Request Body for this API is as follow:
{
"name": String,
"price": Number,
"ingredients": [String]
}All the fields in Pizza Schema are required.
ingredientsArray should have unique items. It should return the pizza object in response. Response Body is as follow:
{
"name": String,
"price": Number,
"ingredients": [String]
}- List of Pizzas (GET
/api/pizzas) (SECURED)
It should return the list of Pizzas. Response should be an Array of Object. Response Body is as follow:
[
{
"name": String,
"price": Number,
"ingredients": [String]
}
]- Update Pizza Ingredients (PATCH
/api/pizzas/:id) (SECURED)
Request Body for this API is as follow:
{
"ingredients": [String]
}Each item from the request must be inserted in
ingredientsArray.ingredientsArray should have unique items. It should return the updated object of Pizza. Response Body is as follow:
{
"name": String,
"price": Number,
"ingredients": [String]
}- Place Order (POST
/api/pizzas/placeOrder) (SECURED)
Request Body for this API is as follow:
{
"pizzaId": String
}For this API you have to mandatorily use
MongoDB Transaction. Retrieve the user Id from the authorization token. It should return object in Response Body as follow:
{
"user": {
"firstName": String,
"lastName": String,
"email": String,
"mobile": Number
},
"pizza": {
"name": String,
"price": Number,
"ingredients": [String]
},
"orderDate": Date,
"isFulfilled": Boolean
}PUBLIC: You dont need to a authorize this APISECURED: Authorization is required to access these APIs