Git Product home page Git Product logo

Comments (7)

andreweinkoetz avatar andreweinkoetz commented on June 3, 2024 1

User endpoints added to checklist 👍

We also need an element endpoint for the different allergies (e.g. lactose, glucose)
/element(s)

And
/lifestyle(s)
/goal(s)

You mean the user-based allergies, lifestyle & goals right? (e.g. /user/:id/allergies)

And last but not least, depending on the data schema, we will need an endpoint to rate substitute according to user feedback (e.g. I like the substitue, I do not like the substitute...)

This is not part of the model yet. In my opinion this should be part of "UserRecipe"-model right?

from foodo-backend.

andreweinkoetz avatar andreweinkoetz commented on June 3, 2024 1

user/:id/goal/:id
user/:id/dislike/:id
user/:id/allergy/:id
user/:id/lifestyle/:id

If we'd model it this way, we would use the id ambiguously.
req.params.id would be one of userId or goalId (e.g.).

Suggestion:
user/:id/lifestyle/:lifeStyleId

or even easier (as you'll send me an object in the body of the request anyway):
user/:id/lifestyle/ with lifestyle as json in body

from foodo-backend.

andreweinkoetz avatar andreweinkoetz commented on June 3, 2024 1

user/:id/recipe/:id (for update)
user/:id/recipe/ (for create)

Implementation as:

user/recipe (PUT) for updating with personalized recipe as JSON in body
user/recipe (POST) for inserting with personalized recipe as JSON in body

We don't need to explicitly set :id for user in this route as the personalized recipe already includes the user's id.

from foodo-backend.

andreweinkoetz avatar andreweinkoetz commented on June 3, 2024 1

Further improvement:

All userId related endpoints will be replaced.
Reason:
The user id is provided with after validating the access token. Selection via req.params is therefore not necessary and can be replaced:

  • i.e. user/:id/allergy/ will be accessible on user/allergy

Added description of this in original post. We need to keep in mind to remove all :id params in user-related routes.

from foodo-backend.

andrelandgraf avatar andrelandgraf commented on June 3, 2024

For the user profile, we need following routes to post and delete:

  • user/:id/goal/:id
  • user/:id/dislike/:id
  • user/:id/allergy/:id
  • user/:id/lifestyle/:id
  • user/:id/locale/:locale (to save 'en' or 'de' as users language preference)

To create and update an user recipe, we need:

  • user/:id/recipe/:id (for update)
  • user/:id/recipe/ (for create)

To get all those information, we already have the endpoint auth/me, to get the current user!

We also need an element endpoint for the different allergies (e.g. lactose, glucose)
/element(s)

And
/lifestyle(s)
/goal(s)

And last but not least, depending on the data schema, we will need an endpoint to rate substitute according to user feedback (e.g. I like the substitue, I do not like the substitute...)

from foodo-backend.

andrelandgraf avatar andrelandgraf commented on June 3, 2024

This is not part of the model yet. In my opinion this should be part of "UserRecipe"-model right?

You are right, it should be!

You mean the user-based allergies, lifestyle & goals right? (e.g. /user/:id/allergies)

Exactly, a user needs to select a goal, lifestyle and allergies from a list of possible values. Those values, e.g. all goals, should be in the database and accessible like recipes or ingredients. :) So that, by calling /user/:id/goal/:id I can add the goal id from the goal endpoint to the user object.

from foodo-backend.

andreweinkoetz avatar andreweinkoetz commented on June 3, 2024

Exactly, a user needs to select a goal, lifestyle and allergies from a list of possible values. Those values, e.g. all goals, should be in the database and accessible like recipes or ingredients. :) So that, by calling /user/:id/goal/:id I can add the goal id from the goal endpoint to the user object.

Got this 👍 i will create a separate issue for the user-related endpoints.

Regarding UserRecipe - how about this model?

const UserRecipeSchema = new Schema( {
    user: {
        type: Schema.Types.ObjectId,
        ref: 'User',
    },
    recipe: {
        id: {
            type: Schema.Types.ObjectId,
            ref: 'Recipe',
        },
        substitutions: [ {
            orig: {
                type: Schema.Types.ObjectId,
                ref: 'Ingredient',
            },
            subs: [ {
                id: {
                    type: Schema.Types.ObjectId,
                    ref: 'Ingredient',
                },
                rating: {
                    type: Schema.Types.Boolean,
                    ref: 'Recipe',
                },
            } ],
        } ],

    },

}, { collection: 'userRecipe' } );

😃

from foodo-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.