Giter Site home page Giter Site logo

good-food-tracker-api's Introduction

Good Food Tracker

Dependency Badge Repo size badge Open issues badge Licence badge Forks badge

All Contributors

The project aims to allow the users to take pictures and/or leave notes, ratings, comments about restaurants they visit in order to be able to reference it later when they try to pick were they want to go eat out or order from.

What is this repository for?

This repository is part of the Good Food Tracker project and is used for the development of the backend system.

For the list of existing or currently being developed feature please refer to the features section of this document.

How do I get set up?

To get started on development follow these steps:

  • Rename .env.example to .env;
    • Add your values to the .env file;
  • Start up docker containers with docker-compose up;
  • Create postgres database;
    • To create the database you can use the pgAdmin web UI;
      • pgAdmin web UI can be accessed at: localhost:${PGADMIN_PORT};
      • login with ${PGADMIN_DEFAULT_EMAIL} and ${DB_PASSWORD}
      • create a server with these connection properties:
        • Host : gft-postgres
        • Port : ${DB_PORT}
      • create a database with these properties:
        • name : ${DB}
        • username : ${DB_USERNAME}
        • password : ${DB_PASSWORD}
    • Rename .migration.example.config into .migration.config;
      • Add your values to the .migration.config file;
    • Run docker-compose exec app php ./cli/migrate.php --init to initialize the migrations table;
    • Run docker-compose exec app php ./cli/migrate.php --up to run all the migrations;
    • Run docker-compose exec app composer install to install php dependencies
  • Visit localhost:${APACHE_PORT} to see if everything is working;

Contribution guidelines

  • Keep code clean and simple;
  • DO NOT alter the database directly, use migrations;
  • Always use branches and pull requests when making changes to the codebase;

Who do I talk to?

  • If you have any question you can contact Igor Ilić via:
  • If you have found a bug or want to ask for a new feature, you can open a new issue

Features

List of currently completed or still being developed feature:

  • Auth
    • Login
    • Register
    • Verify account
    • Reset password
      • Request password reset code
      • Verify reset code & set new password
  • User profile
    • Get user profile information
    • Update user profile information
    • Delete user profile
  • Country
    • List of countries
    • Get single country info
    • Add / edit country
    • Delete country
  • City
    • List of cities
    • Add / edit city
    • Delete city
  • Restaurants
    • List of all the restaurants
    • Fetch info about single restaurant
    • Add / edit restaurant
    • Delete restaurant
  • Reviews
    • List of users reviews
    • Add / edit your review
      • Add / remove image for a review
    • Delete your own review

Notes

Database diagram with current, future and optional tables can be found on dbDiagram.io.

Possible future tables in the database diagram will be positioned on the right side of the diagram. Whereas the existing ones or the ones that are being worked on are positioned on the left side.

Contributors ✨

Thanks go to these wonderful people (emoji key):


negue

🤔

Subham Sahu

💻

Kate Bartolo

📖

Rajakavitha1

📖

skrrra

💻

Ishan Vyas

💻

Abilogos

🐛 📖 💻

This project follows the all-contributors specification. Contributions of any kind welcome!

good-food-tracker-api's People

Contributors

abilogos avatar allcontributors[bot] avatar deepsource-autofix[bot] avatar deepsourcebot avatar dependabot[bot] avatar gigili avatar ishan-deepsource avatar kabartolo avatar rajakavitha1 avatar skrrra avatar subhamx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

good-food-tracker-api's Issues

[Email templates] Create new email template for password resets

When sending the password reset email , would be nice to have a proper email template instead of having just plain text email sent to the user.

For the reference on the email template the confirm email template can be used.

As for the images/logos any placeholder (no explicit content allowed) image will be fine until the proper banners and logos are created.

Here is a screenshot of the email confirmation template:
gft-confirm-email-template

To create email templates you can use services such as Mailchimp to create templets using their UI tools and than export it as single html file.

[Email templates] Create new email template for account deletion

When the user deletes their account, would be nice to have a proper email template instead of having just plain text email sent to the user.

For the reference on the email template the confirm email template can be used.

As for the images/logos any placeholder (no explicit content allowed) image will be fine until the proper banners and logos are created.

Here is a screenshot of the email confirmation template:
gft-confirm-email-template

To create email templates you can use services such as Mailchimp to create templets using their UI tools and than export it as single html file.

[BUG] When using entities save method

Describe the bug
When calling the save method there is a SQL error thrown because the password column value doesn't get set.

SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "password" violates not-null constraint

The issue is in Entities.php:80

Just removing the ReflectionProperty::IS_PUBLIC parameter fixes the issue on the register endpoint but not sure if it breaks anything else.

To Reproduce

$user = new UserEntity();
$user->name = "Tester Test";
$user->email = "[email protected]";
$user->username = "test";
$user->set_password("test123");
$user->save();

Expected behavior
A new user gets added to the database or an existing one gets updated.

[ FEATURE ] When calling delete methods remove any files

Whenever the delete method is called for entities, we should also check if there are any files associated with that entity and if there are, we should remove the from the disk.

  • When a user deletes their account it should remove their profile image if it exists #207
  • When a user updated their profile image, remove the old one if it exists #210
  • #218

[ FEATURE ] Extend validation class to be able to validate custom values

Currently when using the Validation class from the Core\Utility\Validation.php you can only validate data available to you from the Request class which covers all the request body data, but sometimes there is a need to validate some custom data that may not be present in the Request class.

What I'd like to be able to do is, specify the value I want to validate instead of using just the Request class as an argument.

Currently when calling the Validation class we do:

Validation::validate([
		["restaurantID" => [ValidationRules::REQUIRED, ValidationRules::VALID_UUID]],
		["ratingID" => [ValidationRules::REQUIRED, ValidationRules::NUMERIC]]
], $request);

but what I'd like to be able to do is

Validation::validate([
		["restaurantID" => [ValidationRules::REQUIRED, ValidationRules::VALID_UUID]],
		["ratingID" => [ValidationRules::REQUIRED, ValidationRules::NUMERIC]],
                ["name" => [ValidationRules::REQUIRED],
                ["email" => [ValidationRules::REQUIRED, ValidationRules::VALID_EMAIL],
], $request, ["name" => $name, "email" => $email]);

It would be nice if we're able to keep the old functionality as is, but also extend it to support this new one

Reconsider Math.floor for token expiry time

When generating a new access token Math.floor is used to round and update expiry time longer by 2 hours.

This should be reconsider and created in a way were we do not need to relay on the Math functions so that the validity of token can be verified better

Create refresh token endpoint

There needs to be a refresh token generated for a user when they login and stored in the database so that it can be revoked later but while it is active be used to generate a new access token that will allow the user access to the API.

  • Generate refresh token
  • Store the token in the database
  • Create refresh token endpoint ( /token maybe)
  • Validate that the refresh token is valid on request to that endpoint
  • Return new access token as a response
  • Create invalidate / revoke token endpoint (/token again but with delete request to it or maybe /logout )

Reduce user data stored in a token

With the user profile being load from the API there is no need to sto so much information in the token anymore.

Now it would be better if the token only contained the user guid, power level and maybe a full name.

[ FEATURE ] Extend validation class to support numeric value range validations

Is your feature request related to a problem? Please describe.
When using the Validation class we have the ability to validate values to make sure they are of a numeric type, but we are missing options for validating if that value is also constrained in a certain range as well.

Describe the solution you'd like
To have new ValidationRules such as ValidationRules::MINIMUM_VALUE, ValidationRules::MAXIMUM_VALUE, ValidationRules::IN_RANGE

Usage examples

Validation::validate([
  ["restaurantID" => [ValidationRules::REQUIRED, ValidationRules::VALID_UUID]],
  ["ratingID" => [
    ValidationRules::REQUIRED, 
    ValidationRules::NUMERIC, 
    [ValidationRules::MINIMUM_VALUE => 0],
    [ValidationRules::MAXIMUM_VALUE => 100],
    [ValidationRules::IN_RANGE => [0, 100]],
 ]
], $request);

When the user deletes a review, remove all images associated with that review

This module is not yet developed, but once it does get developed we need to implement the functionality that will allow us to remove any images associated with a review when that review gets deleted. This might also happen when someone deletes a restaurant as well, because in that case all the reviews linked to it would be deleted as well so we need to make sure that images get deleted as well. This issue will be updated once the reviews modules gets created

Create API documentation

There needs to exists a documentation of all API endpoints with description of them and their parameters, also certain routes are only available to certain users so that should be noted in the documentation as well.

Suggestions for API documentation tools/libraries:

Here are some articles that might be a good starting point:

Express API with autogenerated OpenAPI doc through Swagger | Dev.to
How we use Open API v3 specification to auto-generate API documentation, code-snippets and clients | Medium

Any feedback and/or helps is much appreciated on this.

Create tests for all the API endpoints

There should be tests created for all the API routes.

Some resources for it:

Testing ExpressJS REST API with Mocha and Chai | Medium
How to Test Nodejs Code and RESTful API | CodeForGeek
Testing NodeJs/Express API with Jest and Supertest | Dev.to
Mocking ExpressJS Request and Response objects | ITNEXT

The projects programming language has changed from typescript to php so these links are no longer useful.
New links:

As always any help and/or feedback is welcomed :)

[ BUG ] When deleting a user account with no image

Describe the bug
When you try to delete a user account with no image set, it throws an error because it tries to delete folder as the full path isn't provided

To Reproduce

  • Crete an account
  • Login to that account
  • Delete the account

Expected behavior
For the account to be deleted without throwing an error

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.