Code Monkey home page Code Monkey logo

treetracker-web-map's Introduction

Tree Tracker Web Map (BackEnd - API)

This project is built using Node.js version 12.19.0.

Project Knowledge Base: https://app.gitbook.com/@greenstand/s/impact-map/

Requirements

  • Node.js 12

Backend Development

To set up your environment for BackEnd development, follow the steps below:

NOTE: We recommend all of these tasks to be executed using Visual Studio Code, openning a Terminal session.

  1. Install node modules, running npm i in the root

    npm i
    
  2. Set up database connection string.

    1. Create a .env file at the folder server.

    2. Add the following content in the .env file

      DATABASE_URL=postgresql://xxxx:xxxx@dxxxx:25060/treetracker?ssl=no-verify
      

      NOTE: The default mode to run the API in the test environment is connecting with the remote database. > * Ask for the db connectiong string on the slack channel.

  3. Install supervisor globally

    npm i -g supervisor
    
  4. Run the Backend Development Environment

    Attention:

    • Option 1 is for BackEnd development only.
    • Option 2 is for FrontEnd and BackEnd development.

    Choose one of the options and Run the code below on the terminal:

    • Option 1:

      NOTE 1: This command will run server.js with CORS restrictions lifted NOTE 2: For environments running the FrontEnd and BackEnd, do not use this option, because API will run at port 3000 conflicting with the React project. Choose option 2.

      NODE_ENV=dev supervisor server.js
      
    • Option 2:

      cd server
      npm run dev
      

      NOTE:

      1. In this way, the server would run on port 3001, and client would run on port 3000.

IMPORTANT NOTE: When running for the first time the API, if the endpoints are not responding, because after the queries there aren't any answer or error, it might be some incompatibility with the node version and pg module. If you are running Node.js 14, downgrade to Node.js 12.19.0. How to Upgrade (or Downgrade) Node.js Using npm


(Optional) Local Database

  • The steps below are required only for scenarios where the API needs to connect with the Postgres database locally.
  • The default mode to run the application is connecting with the remote database, but for some specific scenarios, as an exception, the developer might need to have the database running local.
  • Do not execute these steps if you are configuring the environment for the first time.
  1. Install postgres
  2. Install postGIS
  3. Create a database named 'treetracker'
  4. Import our developer seed into your database.
    • Ask in slack for the link to the seed.
  5. Configure .env to point to your local database.
  6. Run the Backend Development Environmet.

How to test

We use Jest to build tests.

  1. To test server
cd server
npm test

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.