ExpressJS - Simple Note App RESTful API

restfulapi

Table of contents

Introduction

Express.js Node.js

Here i was built the Simple Note App which specially for backend only.

Express.js, or simply Express, is a web application framework for Node.js. More about Express

Requirements

  1. node_modules
  2. Postman
  3. Web Server (ex. localhost)

How to run the app ?

  1. Open CMD or Terminal and enter to the app directory
  2. Type npm install
  3. Make a new file called .env in the root directory, set up first here
  4. Turn on Web Server and MySQL can using Third-party tool like xampp, etc.
  5. Open Postman desktop application or Chrome web app extension that has installed before
  6. Choose HTTP Method and enter request url.(ex. localhost:3000/notes)
  7. You can see all the end point here

Set up .env file

Open .env file on your favorite code editor, and copy paste this code below :

DB_HOST=localhost
DB_USER=root // default
DB_PASS= // default
DB_NAME=simple_note_app

End Point List

/table name
get 10 first data

?where=+(field name)+(value)
example : 3000/tb_product?where=price+10000
query in database : "select * from tb_product where price = 10000"

?search=(field name)+(value)
example : 3000/tb_product?where=name+roti
query in database : "select * from tb_product where name like "%roti%"

?join=(second table+first table field+second table field)
example: 3000/tb_product?where=tb_store+id_product+id_store
query in database :
"select * from tb_product left join tb_store on id_product=id_store"

just (where) end point can be used in POST, GET, PATCH, AND DELETE