Skip to content

BloomTech-Labs/neighborhood-chef-be

Repository files navigation

Neighborhood Chef

The back-end is deployed on AWS RDS at be.ourneighborhoodchef.com

build Maintainability Test Coverage MIT

Contributors

Kyle Richardson Paul Edwards Aaron Merrifield-Lucier Brennan Neilson Patrick Replogle Miguel Leal

API Documentation

Getting started

To get the server running locally:

  • Clone this repo
  • yarn install to install all required dependencies
  • Install Postgres Docker (see section of same name) to setup PostgreSQL Docker development instance
  • yarn server to start the local server

Testing:

  • yarn test to start server using testing environment
  • yarn test:watch to continuously use testing environment
  • yarn test:watchTroubleshoot to debug while using testing environment
  • yarn test:watchWithLogs to view logs while using testing environment
  • yarn coverage to view test coverage

Install Postgres Docker

First, ensure you've created a file named /.env with the same variable names as in the /.env.example file. The values can differ from the examples based on your preferred settings, if desired.

On Windows, it's probably best to setup Windows Subsystem for Linux v2 (WSL2), available in Windows 10, version 2004, and the Microsoft Terminal (preview) app from the Microsoft App Store. Instructions below for Ubuntu Linux can be followed in WSL2 if you install the Ubuntu instance. Docker Desktop for Windows only works on Windows 10 Professional or Enterprise/Workstation editions, it will not install on Home edition. You can use the older docker toolkit on Windows 10 Home and run the script in it's included Bash shell.

Ensure you have installed these pre-requisites:

  • Docker Desktop, docker toolkit, or docker.io Community Edition. Ensure the command line application (docker) is in your path and available when issuing the command docker.
    • Ubuntu Linux: sudo apt install docker.io
    • Windows/macOS: download & install Docker Desktop
  • Postgres command line application (psql) in your path and available when issuing the command psql.
    • Ubuntu Linux: sudo apt install postgresql-client (and its dependencies). You do not need to install the server.
    • Windows/macOS: download PostgreSQL and install at minimum the command line application. If you install the PostgreSQL service, it will conflict with the docker instance we're trying to setup, so be sure to disable the PostgreSQL service provided by the installer if you install it.
  • Knex command line application (knex) globally installed so that it is in your path and available when issuing the command knex.
    • All (in terminal): sudo yarn global add knex or sudo npm i -g knex

Then, ensure the script has execute permission, and run the script in a Bash (Linux/WSL) or Zsh (macOS) Shell session:

cd data; chmod +x postgres-docker.bash; ./postgres-docker.bash

If prompted for a password, input your currently logged-in user's password to perform the requested command as superuser. This assumes your user has the privilege to do so as a "sudoer".

Backend framework

  • Node
  • Express
  • Graphql
  • Knex
  • AWS RDS
  • PostgreSQL

Graphql Queries and Mutations

User

Type Name variables Description
Query getAllUsers none Returns all users
Query getUserById (id: ID!) Returns a single user
Query getUserByEmail (input: UserEmailInput!) Returns a single user
Query getAuthoredEvents (id: ID!) Returns logged in user's events
Query getInvitedEvents (id: ID!) Returns events that user is invited too
Query getAttendingEvents (id: ID!) Returns events user is attending
Query getFavoriteEvents (id: ID!) Returns user's favorite events
Mutation addUser (input: NewUserInput!) Adds a user account
Mutation updateUser (id: ID!, input: UpdateUserInput!) Updates a user account
Mutation removeUser (id: ID!) Deletes a user account
Mutation addFavoriteEvent (input: NewFavoriteEventInput!) Adds an event to user's favorite list
Mutation removeFavoriteEvent (input: RemoveFavoriteEventInput!) Removes event from user's favorite list

Event

Type Name variables Description
Query getAllEvents none Returns all events
Query getEventById (id: ID!) Returns a single event
Query getUninvitedUsers (id: ID!) Returns users not invited to event
Mutation addEvent (input: NewEventInput!) Adds a new event
Mutation updateEvent (id: ID!, input: UpdateEventInput!) Updates an event
Mutation removeEvent (id: ID!) Deletes an event
Mutation inviteUserToEvent (input: EventInviteInput!) Invites user to event
Mutation updateInvitation (input: UpdateInviteInput!) Update invitation status
Mutation removeInvitation (input: RemoveInviteInput!) Deletes an invitation

Category

Type Name variables Description
Query getCategories none Returns all categories
Query getCategoryById (id: ID!) Returns a single category
Mutation addCategory (input: NewCategoryInput!) Adds a new category

Comments

Type Name variables Description
Query getEventComments (id: ID!) Returns all event comments
Query getCommentReactions (id: ID!) Returns all comment reactions
Mutation addComment (id: ID!) (input: !NewCommentInput)
Mutation updateComment (id: ID!, input: !NewCommentInput) Returns updated comment
Mutation removeComment (id: ID!) Returns deleted comment
Mutation handleReaction (input: ReactionInput!) Dynamically adds, updates, or deletes reaction

Event Ingredients

Type Name variables Description
Query getIngredientsByEventId (event_id: Int!) Returns all event ingredients
Mutation addEventIngredients (input: EventIngredientsInput!) Adds event ingredients
Mutation EventIngredientUpdate (input: EventIngredientUpdateInput ) Updates event ingredients
Mutation removeEventIngredient (id: ID!) Returns deleted comment

Data Model

User Type and Inputs

  type User {
    id: ID!
    email: String!
    firstName: String!
    lastName: String!
    gender: String
    address: String!
    latitude: Float!
    longitude: Float!
    photo: String
    eventsOwned: [Event]!
    status: String
    allergens: JSON
    dietaryRestrictions: JSON
    dietaryPreferences: JSON
    children: JSON
    pets: JSON
  }
  input NewUserInput {
    id: ID
    email: String!
    firstName: String!
    lastName: String!
    gender: String
    address: String!
    latitude: Float!
    longitude: Float!
    photo: String
    allergens: JSON
    dietaryRestrictions: JSON
    dietaryPreferences: JSON
    children: JSON
    pets: JSON
  }
  input UpdateUserInput {
    id: ID
    email: String
    firstName: String
    lastName: String
    gender: String
    address: String
    latitude: Float
    longitude: Float
    photo: String
    allergens: JSON
    dietaryRestrictions: JSON
    dietaryPreferences: JSON
    children: JSON
    pets: JSON
  }
  input UserEmailInput {
    email: String!
  }

Event Type and Inputs

  type Event {
    id: ID!
    startTime: String!
    endTime: String
    createDateTime: String!
    title: String!
    description: String!
    photo: String!
    category_id: Int!
    user_id: Int!
    modifiers: JSON
    hashtags: JSON
    dietaryWarnings: JSON
    allergenWarnings: JSON
    address: String!
    latitude: Float!
    longitude: Float!
    users: [User!]
  }
  input NewEventInput {
    id: ID
    createDateTime: String
    startTime: String!
    endTime: String
    title: String!
    description: String!
    user_id: Int!
    photo: String
    category_id: Int!
    modifiers: JSON
    hashtags: JSON
    dietaryWarnings: JSON
    allergenWarnings: JSON
    address: String!
    latitude: Float!
    longitude: Float!
  }
  input UpdateEventInput {
    id: ID
    startTime: String
    endTime: String
    title: String
    description: String
    photo: String
    category_id: Int
    user_id: Int
    modifiers: JSON
    hashtags: JSON
    dietaryWarnings: JSON
    allergenWarnings: JSON
    address: String
    latitude: Float
    longitude: Float
  }

EventInvite Inputs

  input EventInviteInput {
    event_id: Int!
    user_id: Int!
    inviter_id: Int!
    status: String!
  }
  input UpdateInviteInput {
    event_id: Int!
    user_id: Int!
    status: String!
  }
 input RemoveInviteInput {
    event_id: Int!
    user_id: Int!
  }

Category Type and Inputs

  type Category {
    id: ID!
    category: String!
  }
 input NewCategoryInput {
    id: ID
    category: String!
  }

Event Ingredient Type and Inputs

  type EventIngredient {
    id: ID!
    event_id: Int!
    description: String!
    requested: Boolean! 
    user_id: Int
  }
 input EventIngredientsInput {
    ingredients: [EventIngredientInput]
  }
  input EventIngredientInput {
    event_id: Int!
    description: String!
    requested: Boolean! 
    user_id: Int
  }
  input EventIngredientUpdateInput {
    id: ID
    event_id: Int
    description: String
    requested: Boolean 
    user_id: Int
  }

comment/reactions Type and Inputs

  type Comment {
    id: ID!
    event_id: Int!
    user_id: Int!
    parent_id: Int!
    root_id: Int!
    dateCreated: String!
    comment: String!
    user: User!
  }
  input NewCommentInput {
    id: ID
    event_id: Int!
    user_id: Int!
    parent_id: Int!
    root_id: Int!
    dateCreated: String!
    comment: String!
  }
  input UpdateCommentInput {
    id: ID
    event_id: Int
    user_id: Int
    parent_id: Int
    root_id: Int
    dateCreated: String
    comment: String
  }
type Reaction {
    comment_id: Int!
    user_id: Int!
    reaction: String!
  }
  input ReactionInput {
    comment_id: Int!
    user_id: Int!
    reaction: String!
  }

Environment Variables

In order for the app to function correctly, the user must set up their own environment variables. Please refer to the .env.example file contained within the src folder for a list of up to date environment variables with examples.

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct. Please follow it in all your interactions with the project.

Issue/Bug Request

If you are having an issue with the existing project code, please submit a bug report under the following guidelines:

  • Check first to see if your issue has already been reported.
  • Check to see if the issue has recently been fixed by attempting to reproduce the issue using the latest master branch in the repository.
  • Create a live example of the problem.
  • Submit a detailed bug report including your environment & browser, steps to reproduce the issue, actual and expected outcomes, where you believe the issue is originating from, and any potential solutions you have considered.

Feature Requests

We would love to hear from you about new features which would improve this app and further the aims of our project. Please provide as much detail and information as possible to show us why you think your new feature should be implemented.

Pull Requests

If you have developed a patch, bug fix, or new feature that would improve this app, please submit a pull request. It is best to communicate your ideas with the developers first before investing a great deal of time into a pull request to ensure that it will mesh smoothly with the project.

Remember that this project is licensed under the MIT license, and by submitting a pull request, you agree that your work will be, too.

Pull Request Guidelines

  • Ensure any install or build dependencies are removed before the end of the layer when doing a build.
  • Update the README.md with details of changes to the interface, including new plist variables, exposed ports, useful file locations and container parameters.
  • Ensure that your code conforms to our existing code conventions and test coverage.
  • Include the relevant issue number, if applicable.
  • You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

Attribution

These contribution guidelines have been adapted from this good-Contributing.md-template.

Documentation

See Frontend Documentation for details on the fronend of our project.

About

No description or website provided.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors