/node-express-rest-api

A simple REST API based on Node.js, Express.js and SQLite

Primary LanguageJavaScript

Node Express REST API

Running

  1. npm install

  2. npm run seed, to create a database in database.sqlite3.

  3. npm start.

Specification

Data Models

Profile

A profile can be either a client or a contractor. clients create contracts with contractors. contractor does jobs for clients and get paid. Each profile has a balance property.

Contract

A contract between and client and a contractor. Contracts have 3 statuses, new, in_progress, terminated. contracts are considered active only when in status in_progress Contracts group jobs within them.

Job

contractor get paid for jobs by clients under a certain contract.

APIs

  1. GET /contracts/:id

  2. GET /contracts

  3. GET /jobs/unpaid

  4. POST /jobs/:job_id/pay

  5. POST /balances/deposit/:userId

  6. GET /admin/best-profession?start=<date>&end=<date>

  7. GET /admin/best-clients?start=<date>&end=<date>&limit=<integer>