Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devdbrandy/ireporter
iReporter app enables users (citizen) to bring any form of corruption to the notice of appropriate authorities and the general public
https://github.com/devdbrandy/ireporter
citizen citizen-participation corruption development intervention notice rest-api
Last synced: 6 days ago
JSON representation
iReporter app enables users (citizen) to bring any form of corruption to the notice of appropriate authorities and the general public
- Host: GitHub
- URL: https://github.com/devdbrandy/ireporter
- Owner: devdbrandy
- License: mit
- Created: 2018-11-19T13:30:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-03T19:13:13.000Z (over 3 years ago)
- Last Synced: 2024-12-05T10:12:56.121Z (2 months ago)
- Topics: citizen, citizen-participation, corruption, development, intervention, notice, rest-api
- Language: JavaScript
- Homepage: https://irepot.herokuapp.com
- Size: 3.79 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
iReporter
# Overview
iReporter app enables users (citizen) to bring any form of corruption to the notice of appropriate authorities and the general public. Visit iReporter live demo: [https://devdbrandy.github.io/iReporter](https://devdbrandy.github.io/iReporter).
>Demo Users
>
>| Username | Password | Access |
>|-----------|----------|--------------|
>| `admin` | `secret` | Admin Access |
>| `user123` | `secret` | User Access |- [Overview](#overview)
- [1. :rocket: Getting Started](#1-rocket-getting-started)
- [1.1 Prerequisites](#11-prerequisites)
- [1.2. Run locally](#12-run-locally)
- [1.3. Building](#13-building)
- [1.4. Test Locally](#14-test-locally)
- [1.5. Running Test](#15-running-test)
- [2. :lock: Authentication](#2-lock-authentication)
- [3. API Versioning](#3-api-versioning)
- [4. HTTP Requests](#4-http-requests)
- [5. HTTP Response Codes](#5-http-response-codes)
- [:bookmark: 6. Resources](#bookmark-6-resources)
- [6.1. Authentication](#61-authentication)
- [6.2. API Routes](#62-api-routes)
- [7. :pencil: License](#7-pencil-license)## 1. :rocket: Getting Started
### 1.1 Prerequisites
Ensure that you have the following installed on your local machine:
- [NodeJS](https://nodejs.org/en/download/)
- [PostgreSQL](https://www.postgresql.org/download/)### 1.2. Run locally
- To run app locally, make sure you have `nodejs`, `postgres` installed.
- Clone repository or clone your own fork```bash
git clone https://github.com/devdbrandy/iReporter.git
cd iReporter
cp .env.example .env
npm install
```- Create a PostgreSQL database for the project via `pgAdmin` or run the below command on your terminal:
```bash
createdb -h localhost -p 5432 -U postgres ireporter
```- Configure `.env` environment variable with your credentials
- Run migration `npm run migrate`
- (Optional) Seed dummy data `npm run db:seed`
- Two npm scripts are availiable to spin up the app server:
- `npm run dev` spin up the server without watching for any file changes
- `npm run watch` watches for any file changes and reloads the server### 1.3. Building
`npm run build`
### 1.4. Test Locally
To test or consume api locally, you can make use of [*Postman*](https://www.getpostman.com) or [*Insomnia*](https://insomnia.rest/download/)
### 1.5. Running Test
Test specs are implemented using [*mocha*](https://mochajs.org) + [*chai*](https://chiajs.com) + [*sinon*](https://sinonjs.org).
Make a duplicate of `.env` and rename to `.env.test`, then configure your test credentials.
Two npm scripts are available to run the test suite:
1. `npm run mocha` or `npm run mocha:watch` - The later watches for any file changes and runs the full test suite (without code coverage)
2. `npm test` - Performs a single full test suite run, including instanbul code coverage reporting. Summary coverage reports are written to stdout, and detailed HTML reports are available in `/coverage/index.html`## 2. :lock: Authentication
Access to restricted API endpoints requires an access token, iReporter uses access tokens to associate API requests with your account. To obtain your access token, make a request along with `username` and `password` credentials to `https://irepot.herokuapp.com/auth/login`
**Sample Response:**
```http
POST https://irepot.herokuapp.com/auth/login
HTTP/1.1
Accept: application/jsonHTTP/1.1 200 OK
Content-Type: application/json{
"status": 200,
"data": [
{
"token": "...",
"user": {}
}
]
}
```## 3. API Versioning
The second part of the URI specifies the API version you wish to access in the format `v{version_number}`.
For example, version 1 of the API (most current) is accessible via:```http
https://irepot.herokuapp.com/api/v1
```## 4. HTTP Requests
All API requests are made by sending asecure HTTPS request using one of the following methods, depending on the being taken:
- `POST` Create a resource
- `PATCH` Update a resource
- `GET` Get a resource or list of resources
- `DELETE` Delete a resourceFor `POST` and `PATCH` requests, the body of your request may include a JSON payload.
## 5. HTTP Response Codes
Each response will be returned with one of the following HTTP status codes:
- `200` `OK` The request was successful
- `400` `Bad Request` There was a problem with the request (security, malformed)
- `401` `Unauthorized` The supplied API credentials are invalid
- `403` `Forbidden` The credentials provided do not have permissions to access the requested resource
- `404` `Not Found` An attempt was made to access a resource that does not exist in the API
- `500` `Server Error` An error on the server occurred## :bookmark: 6. Resources
### 6.1. Authentication
| URI | HTTP Method | Description |
|------------------------------------------------------------|:-----------:|----------------|
| [**/auth/signup**
](/docs/auth/POST_signup.md) | `POST` | Create new account |
| [**/auth/login**
](/docs/auth/POST_login.md) | `POST` | Login into account |### 6.2. API Routes
| URI | HTTP Method | Description |
|-----|:-----------:|-------------|
| [**/api/v1/users**
](/docs/users/GET_list.md) | `GET` | Fetch all users |
| [**/api/v1/users/{id}**
](/docs/users/GET_id.md) | `GET` | Fetch a single user by ID |
| [**/api/v1/users/{id}**
](/docs/users/PUT_id.md) | `PUT` | Update entire user resource |
| [**/api/v1/records**
](/docs/records/GET_list.md) | `GET` | Fetch all records |
| [**/api/v1/red-flags**
](/docs/red_flags/GET_list.md) | `GET` | Fetch all red-flag records |
| [**/api/v1/red-flags/{id}**
](/docs/red_flags/GET_id.md) | `GET` | Fetch a single red-flag by ID record |
| [**/api/v1/red-flags**
](/docs/red_flags/POST_create.md) | `POST` | Create a new red-flag record |
| [**/api/v1/red-flags/{id}/location**
](/docs/red_flags/PATCH_location.md) | `PATCH` | Update a red-flag's location |
| [**/api/v1/red-flags/{id}/comment**
](/docs/red_flags/PATCH_comment.md) | `PATCH` | Update a red-flag's comment |
| [**/api/v1/red-flags/{id}**
](/docs/red_flags/DELETE_id.md) | `DELETE` | Delete a red-flag by ID |
| [**/api/v1/interventions**
](/docs/interventions/GET_list.md) | `GET` | Fetch all intervention records |
| [**/api/v1/interventions/{id}**
](/docs/interventions/GET_id.md) | `GET` | Fetch all intervention records |
| [**/api/v1/interventions**
](/docs/interventions/POST_create.md) | `POST` | Create a new intervention record |
| [**/api/v1/interventions/{id}/location**
](/docs/interventions/PATCH_location.md) | `PATCH` | Update an intervention's location |
| [**/api/v1/interventions/{id}/comment**
](/docs/interventions/PATCH_comment.md) | `PATCH` | Update an intervention's comment |
| [**/api/v1/interventions/{id}**
](/docs/interventions/DELETE_id.md) | `DELETE` | Delete an intervention by ID |## 7. :pencil: License
The iReporter REST API is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).