API Fundamentals, authentication, encryption, and persistence
git clone https://github.com/rudolphh/express-bp.git
cd express-bp
npm install
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.
Make sure to have MySQL installed for your OS.
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
npm run start
Verify the deployment by navigating to your server address localhost:3030/hello in your favorite browser
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
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
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 |
Want to contribute? Great!
MIT
Free Software, Heaven Yeah!