Giter VIP home page Giter VIP logo

rajmohan6268 / node-mysql-rest-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joemanequinto/node-mysql-rest-api

0.0 0.0 0.0 2.56 MB

๐Ÿ‘Œ๐Ÿป A boilerplate application for building RESTful APIs Microservice in Node.js using Express and Sequelize-MySQL in ES6 with JsonWebToken Authentication and Node-Casbin authorization access control.

JavaScript 98.51% Shell 1.49%

node-mysql-rest-api's Introduction

node-mysql-rest-api

Simple Node.js Boilerplate for simple Node.js Applications. Inspired by septa97's node-boilerplate, Kunal Kapadia's express-mongoose-es6-rest-api, and brianschardt's node_rest_api_mysql

Build Status Commitizen friendly

A boilerplate for building applications in Node.js using ES6 with Code Coverage. Follows Airbnb's Javascript Style Guide.

Features

Feature
ES6 using Babel
Run tests using Mocha
Code linting using ESLint
Automatic syntax formatting using prettier
Auto-restart server using nodemon
Logging using debug
HTTP access control using cors
Authorization access control using node-casbin
API parameter validation using express-validation
Code coverage using istanbul
HTTP status code and message http-status
Consistent commit syntax using commitizen and AngularJS's commit message convention
Precommit hook by running the linter and code coverage tool
Authentication using Passport.js and JSON Web Tokens
Password hashing using bcryptjs

Installing / Getting started

Clone the repository and name it as you like.

git clone https://github.com/JoemaNequinto/node-mysql-rest-api.git <your-project-name>
cd your-project-name/
rm -rf .git/ && git init
git remote add origin https://github.com/<USERNAME>/<REPOSITORY>.git
npm run --silent create
cp .env.example .env
rm README.md
mv README.sample.md README.md
npm install

Then fill up the prompt for modifying the package.json.

You must delete the .git folder and re-initialize it using git init.

You must also create a new README.md. Open the new README.md then modify it depending on your project.

The above code installs the dependencies, creates an environment file, and modifies the package.json file.

MySQL create database

Simple script to create MySQL database and user.

cd scripts/
sudo chmod 755 mysql-db-create.sh
sudo ./mysql-db-create.sh <dbname> <dbuser> <password>

You must enter the password of MySQL root user.

You must change the values of DB_NAME, DB_USER, DB_PASSWORD in .env with dbname, dbuser, password

The above code creates a MySQL database, user and password; modifies the .env file.

Developing the application

To start developing with code linter,

npm run dev

Add an access to a route for a certain role

Edit the policy.csv file in src/lib/acl/

Add an entry:

1st column - p

2nd column - sub (role eg. admin)

3rd column - obj (resource or route eg. /users)

4th column - act (method eg. POST, GET, PUT, DELETE)

For more info, read the casbin documentation.

Making a commit

To safely follow the standards of a commit,

npm run cm

then follow the instructions.

Tests

To run tests,

npm run test

node-mysql-rest-api's People

Contributors

joemanequinto avatar dependabot[bot] 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.