Skip to content

Latest commit

 

History

History
109 lines (85 loc) · 2.53 KB

File metadata and controls

109 lines (85 loc) · 2.53 KB

node-api

Node JS CRUD API Example

Table of Contents

⚙ Install

git clone https://github.com/nmatei/node-api.git
cd node-api
npm install

Usage

npm start
# or (when you work inside code and want auto restart)
npm run devstart

Open http://localhost:3000 to see if it works

JSON file as storage

Team members are stored inside data/teams.json

// GET teams-json
fetch("http://localhost:3000/teams-json", {
  method: "GET",
  headers: {
    "Content-Type": "application/json"
  }
});

// POST teams-json/create
fetch("http://localhost:3000/teams-json/create", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    promotion: "WON3",
    members: "Your Name",
    name: "CV",
    url: "https://github.com/nmatei/teams-networking"
  })
});

// DELETE teams-json/delete
fetch("http://localhost:3000/teams-json/delete", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ id: "fedcba1610309909431" })
});

// PUT teams-json/update
fetch("http://localhost:3000/teams-json/update", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    id: "fedcba1610310163146",
    promotion: "WON3",
    members: "UpdatedName",
    name: "Name",
    url: "https://github.com/nmatei/teams-networking"
  })
});

DB (MySQL) as storage

Team members are stored in MySQL

TODOs

in case port us used...

  • give hints...
  • and change port if not possible.

add port config