GithubHelp home page GithubHelp logo

almoggutin / node-express-rest-api-mysql-js-example Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 8.0 273 KB

Basic REST API example that is built with Node.js and Express in JavaScript. Database connection with MySQL with mysql2 library.

JavaScript 100.00%
nodejs crud express mysql mysql2 rest-api sql

node-express-rest-api-mysql-js-example's Introduction

Node.js Express REST API MySQL JS Example

This REST API example is a basic backend application to test basic API functions with MySQL database.

View Postman Files
Table of Contents
  1. About The Application
  2. How To Install
  3. Available Scripts
  4. Postman

About The Application

This REST API example is a basic backend application to test basic API functions with MySQL database.

It is built with Node.js and Express Framework with Javascript. In addition, the applications database is MySQL, with the use of mysql2 library.

In the applicaiton we can manage user data, such as create/edit/delete a user. In addition, we can get all the users in the database.

The point of this backend application is to test CRUD operations with MySQL database.

(back to top)

Built With

(back to top)

How To Install

Git clone

git clone https://github.com/almoggutin/Node-Express-REST-API-MySQL-JS-Example

Instructions

  • After cloning the the repository run npm i in order to install all the dependencies.
  • Create an env file in the root of the project named .env and fill in the follwing variables: PORT, DB_HOST, DB_PORT, DB_USERNAME, DB_USERNAME_PASSWORD, DB_NAME.
  • In the sql directory, there are sql files that you will need to execute in order to initialize the database.

(back to top)

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the production mode.
However, this script is only meant to be run when deploying the application. The application is built, where you need to setup the env variables on the machine that you will be hosting it on or on a web hosting service, unlike in development mode.

npm run dev

Runs the app in the development mode.
Open localhost on the port you decided on in the env variables to view it in the browser.

The API will reload if you make edits with the use of nodemon.

(back to top)

Postman

If you would like to run the files locally on your machine in the postman desktop application, included in the repository, in the postman directory all the files so you can import them. In addition you will have to configure env variables in postman so that you will be able to test properly everything.

Postman global env variables. Postman admin env variables.

(back to top)

node-express-rest-api-mysql-js-example's People

Contributors

almog-gutin-old avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.