Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

CodingGardenCommunity/app-backend

Repository files navigation

License: MIT GitHub package.json version Travis (.org) branch Libraries.io dependency status for GitHub repo GitHub contributors GitHub commit activity

Coding Garden Community App API

This repository contains the source files and documentation for the API of the Coding Garden Community App. For more information about the Community App please visit the App Wiki.

Running the API locally

NOTE: If you find yourself in some trouble going through this, reach out to us directly on our Discord server.

Prerequisites

  1. NodeJS:
    Please install NodeJS >= 10.15.0. If you already have it, you're good to go.

  2. Yarn:
    Visit Yarn download page. Select your Operating system and follow the instructions. It's as easy as eating a 🍰.

  3. EditorConfig:
    Please visit EditorConfig -> Download a Plugin section and scroll through to see if you need to install an additional Plugin/Extension for your code editor or IDE. If your IDE needs one, you should be able to find a link to that plugin/extension on that page.

    This prerequisite is directly related to: .editorconfig in the root directory of this project.

    More About EditorConfig:
    EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.


Once you have the Prerequisites covered:

  1. Clone this repository from GitHub onto your local computer.

    $ git clone https://github.com/CodingGardenCommunity/app-backend.git
  2. Navigate into the project folder and install all of its necessary dependencies with Yarn.

    $ cd app-backend
    $ yarn install
  3. Install MongoDB and make sure it's running

  4. Make a copy of .env.sample and rename it to .env. You can do so with this simple command:

    NOTE: If you are using Windows Command Prompt, you need to use copy instead of cp.

    $ cp .env.sample .env

    You don't need to change any values in .env file. The default values work well for development purposes.

  5. Once you have MongoDB and .env file ready, seed the local database by running:

    $ yarn run seed
  6. To make sure everything is setup properly, run tests.

    $ yarn run test

    If all tests pass, we can safely conclude that setup is complete and its working as expected. 🙌 Wooh!!
    If not, don't worry. We are together on this mission!! Reach out to us on our Discord server.

  7. Once that's done, tap your back. You are ready to start contributing 😃
    You can run -

    $ yarn run dev

    to start the server.

You can now visit http://localhost:3000/ to view the APIs.

Further, checkout package.json file to learn about (more) available scripts/commands.

Happy coding! 🥂

Dependencies used

  • Express: Web application framework designed for building web applications and APIs.
  • mongoose: Schema based object modeling for mongoDB.
  • joi: Object schema validation library.
  • CORS: Express middleware to enable CORS functionalities.
  • dotenv: For setting environment variables.
  • Swagger UI Express: Auto-generated API docs, based on a swagger.json file.
  • ESLint: Code linter. Analyses the code for potential errors.
    • This project uses ESLint in conjunction with another dependency called "eslint-config-airbnb" for implementing the airbnb set of rules helping to write clean javascript.
  • Jest: For testing.