rudolphh / express-bp

Basic APIs with Express, Authentication with JWT, Encryption with Bcrypt, And Persistence with MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express Basics, and using JWT, Bcrypt, MySQL

API Fundamentals, authentication, encryption, and persistence

Installation

Download here OR

git clone https://github.com/rudolphh/express-bp.git
cd express-bp
npm install

Environment

Create a .env file in the root directory of the project with the following

PORT=3030
DB_PORT=3306
DB_HOST=localhost
DB_USER=root
DB_PASS=root
DB_NAME=express_bp_db
SECRET_KEY=somekindofsecrettext

These can be adjusted to your preference, but DB_NAME is the name of the database schema the seeder will use to automatically create some initial data for you in the database.

MySQL Installation

Make sure to have MySQL installed for your OS.

Docker MySQL

Use the link above for instructions, or if you have Docker use the docker-compose.yml file in the root folder.
In the project root, just run the command:

docker-compose up -d

Run

npm run start

Verify the deployment by navigating to your server address localhost:3030/hello in your favorite browser

Test routes

If you don't have Postman, or don't care to use it there is a test.rest file in the root directory.
This uses the Rest Client extension within VSCode for simple API testing Image of test.rest

Challenge

Build a resource (e.g. Book/Books) by adding appropriate routes, controller, and use middlewares

Example:

GET /books - retrieve ALL books
POST /book - create (insert) a new book
GET /book/id - get the book with the corresponding id
PUT /book/id - update a book with the corresponding id
DELETE /book/id - delete a book with the corresponding id

SQL update and delete statements can be found here

Note: It doesn't have to be about books, use your imagination for the kind of data you'd like to share

Used within the Project

Technology Description
node.js Evented I/O for the backend
Express Fast node.js network app framework @tjholowaychuk
jsonwebtoken An implementation of JSON Web Tokens
bcrypt A library to help you hash passwords.
mysql2 MySQL client for Node.js with focus on performance
dotenv Loads environment variables from .env file

Development

Want to contribute? Great!

License

MIT

Free Software, Heaven Yeah!

About

Basic APIs with Express, Authentication with JWT, Encryption with Bcrypt, And Persistence with MySQL


Languages

Language:JavaScript 97.5%Language:HTML 2.5%