Giter Site home page Giter Site logo

incident-reporting's Introduction

Incident Reporting System

Description

The Incident Reporting System is a Node.js application for managing incident reports for insurance clients. It allows users to submit incident reports with details such as description, city, and country, and integrates with an external weather API to fetch weather data for each incident. The system provides endpoints for creating, retrieving, and filtering incident reports.

Features

  • Submit new incident reports
  • Retrieve incident reports by country
  • Filter incident reports by city, temperature range, and humidity
  • ...

Technologies Used

  • Node.js
  • Express.js
  • PostgreSQL
  • Sequelize ORM
  • OpenWeatherMap API
  • Mocha and Chai for testing

Setup

  1. Clone the repository:

    git clone https://github.com/Joshua-png/Incident-Reporting.git
  2. PostgreSQL server:

    Run or install a local PostgreSQL server to have the ability to run tests on this project.

  3. Install dependencies:

    cd Incident-Reporting
    npm install
  4. Set up environment variables:

    Create a .env file in the root directory and add the following variables:

    PORT = PORT
    NODE_ENV = NODE_ENV
    DB_URL=postgres://username:password@hostname/databaseName
    OPENWEATHERMAP_API_KEY= OPENWEATHERMAP_API_KEY
    

    Replace username, password, and OPENWEATHERMAP_API_KEY with your PostgreSQL credentials when deployed on render and OpenWeatherMap API key.

  5. Set up environment variables for test:

    Create a .env.test file in the root directory and add the following variables:

    PORT = port
    NODE_ENV = test
    OPENWEATHERMAP_API_KEY= OPENWEATHERMAP_API_KEY
    DB_USERNAME_TEST=username
    DB_PASSWORD_TEST=password
    DB_HOST_TEST=host
    DB_PORT_TEST=dbport
    

    Replace username, password, OPENWEATHERMAP_API_KEY,host, dbport with your PostgreSQL credentials from your local Postgres.

  6. Run tests:

    Run this command once and then use the other whenever you want to run tests

    npm run test:setup

    after

    npm run test
  7. Start the server:

    npm start / npm run dev
  8. Access the application:

    The application will be running at http://localhost:3000.

  9. Access the application online:

    The application will be running at https://incident-reporting.onrender.com

Usage

  1. Create a new incident report:

    Send a POST request to /api/v1/incidents with the following JSON payload:

    {
      "incident_desc": "Description of the incident",
      "city": "City Name",
      "country": "Country Name"
    }
  2. Retrieve all incident reports by country:

    Send a POST with a body contain the countryName request to /api/v1/incidents.

  3. Filter incident reports:

    You can filter incident reports by appending query parameters to the endpoint:

    • /api/v1/incidents?city=CityName
    • /api/v1/incidents?temperature_max=temp_max&temperature_min=temp_min
    • /api/v1/incidents?humidity=humidity

incident-reporting's People

Contributors

joshua-png avatar

Watchers

 avatar

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.