All Projects → fraigo → node-express-rest-api-example

fraigo / node-express-rest-api-example

Licence: other
A Basic Node.js/Express REST API implementation example

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-express-rest-api-example

trivin
⚡️Setup your entire project quickly and easily with 1-line command ⚡️
Stars: ✭ 58 (+45%)
Mutual labels:  expressjs
mock-req-res
Extensible mock req / res objects for use in unit tests of Express controller and middleware functions.
Stars: ✭ 39 (-2.5%)
Mutual labels:  expressjs
Books-Library-API
A starter template for building a restful API with nestjs, nodejs , expressjs , monogdb, mongoose
Stars: ✭ 21 (-47.5%)
Mutual labels:  expressjs
watson-discovery-analyze-data-breaches
A Node.js application that demonstrates how to Import, Enrich, and see Insights about data using Watson Discovery.
Stars: ✭ 20 (-50%)
Mutual labels:  expressjs
roboserver
Control OpenComputers robots without writing any code!
Stars: ✭ 52 (+30%)
Mutual labels:  expressjs
express-api-structure
Structure for Express based API server
Stars: ✭ 79 (+97.5%)
Mutual labels:  expressjs
api-server
📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 48 (+20%)
Mutual labels:  expressjs
deepword
Web editor based on Monaco
Stars: ✭ 25 (-37.5%)
Mutual labels:  expressjs
spotify-auth-code-example-vue
VueJS boilerplate app with Spotify API authentication and data fetching.
Stars: ✭ 12 (-70%)
Mutual labels:  expressjs
cafecito
Cafecito es un proyecto hecho en Next.JS con Express.JS y MongoDB para recibir cafés ☕️ a modo de donaciones.
Stars: ✭ 95 (+137.5%)
Mutual labels:  expressjs
buddies-tube
A video streaming platform
Stars: ✭ 14 (-65%)
Mutual labels:  expressjs
vector-tiles-generator
Easily generating mapbox vector tiles from postgis database (without mapnik dependency)
Stars: ✭ 20 (-50%)
Mutual labels:  expressjs
mern-chatting-app
Chatting application where you can join different rooms and chat with people from around the globe.
Stars: ✭ 39 (-2.5%)
Mutual labels:  expressjs
QuickStarter
Quick nodejs (Express) + docker + mongodb + JEST(testing) setup.
Stars: ✭ 12 (-70%)
Mutual labels:  expressjs
Fullstack-projects-frontend-with-react-and-backend-with-various-stacks
* W.I.P *🛠 Full-on full stack front end and a bit of back end web development challenge. Challenging every day to learn new stuffs about react & its in-depth features and also to explore the taste of various stacks.
Stars: ✭ 100 (+150%)
Mutual labels:  expressjs
nestjs-cookie-session
Idiomatic Cookie Session Module for NestJS. Built on top of `cookie-session` 😻
Stars: ✭ 35 (-12.5%)
Mutual labels:  expressjs
Book-Trading-Club
A sample application using node.js api and vuejs
Stars: ✭ 20 (-50%)
Mutual labels:  expressjs
okta-graphql-react-express-example
Web App with Express, React and GraphQL
Stars: ✭ 20 (-50%)
Mutual labels:  expressjs
passport-examples
A variety of examples using PassportJS with ExpressJS and ReactJS applications
Stars: ✭ 44 (+10%)
Mutual labels:  expressjs
react-point-of-sale
A simple point of sale app built in nodejs and reactjs
Stars: ✭ 185 (+362.5%)
Mutual labels:  expressjs

node-express-rest-api-example

A Basic Node.js/Express REST API implementation example.

Full Tutorial at https://developerhowto.com/2018/12/29/build-a-rest-api-with-node-js-and-express-js/

Prerequisites

For Windows

  • Python 2.7 (for microsoft build tools)
  • Install Microsoft build tools (to build sqlite using node-gyp)
  • Node-gyp (npm install --global node-gyp)

Usage

  • Run npm install to installl dependencies
  • Run npm run start to start the local server
  • Load http://localhost:8000 to test the endpoint. It will display a json result {"message":"Ok"}

API Endpoints

GET /api/users

Get a list of users

{
  "message": "success",
  "data": [
    {
      "id": 1,
      "name": "admin",
      "email": "[email protected]",
      "password": "a66abb5684c45962d887564f08346e8d"
    },
    {
      "id": 2,
      "name": "user",
      "email": "[email protected]",
      "password": "4da49c16db42ca04538d629ef0533fe8"
    }
  ]
}

GET /api/user/{id}

Get user information by user id

{
  "message": "success",
  "data": {
    "id": 1,
    "name": "admin",
    "email": "[email protected]",
    "password": "a66abb5684c45962d887564f08346e8d"
  }
}

POST /api/user/

To create a new user based on POST data (x-www-form-url-encoded)

  • name: User name
  • email: User email
  • password: User password

Postman example

PATCH /api/user/{id}

To update user data by id, based on POST data (x-www-form-url-encoded)

  • name: User name
  • email: User email
  • password: User password

You can send only one attribute to update, the rest of the info remains the same.

In this example, using CURL you can update the user email:

curl -X PATCH -d "[email protected]" http://localhost:8000/api/user/2

DELETE /api/user/{id}

To remove a user from the database by user id.

This example is using the curl command line

curl -X "DELETE" http://localhost:8000/api/user/2

The result is:

{"message":"deleted","rows":1}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].