This repo is a demo of an api driven application, using JWT's for authentication and a mongodb backend.
There are many benefits of building an API driven application, notably for its ability to be consumed by many different types of clients (eg. mobile, web, IoT).
Contained in this repo:
frontend/- frontend javascript in the browserbackend/- our api built on Nodejs, MongoDB, Express and various middlewares.
The repository can be run without much setup using Docker/docker-compose.
You'll need to install Docker for Mac, Docker for Windows, or Docker for Linux
Once Docker is installed, you will be able to build and run docker-compose (bundled with docker)
Type:
docker-compose build
docker-compose upThat's it, you should be able to open your browser to view the application http://localhost:3000 for the frontend and http://localhost:8000 for the backend.
You will first need:
- mongodb
- Nodejs v8.0
- npm v5.0
Alternatively, you can open two terminal sessions and navigate to each respective folder, frontent/ and backend/, respectively.
First, make sure your mongodb server is running, usually by mongod or brew services start mongodb
Then, for your backend:
cd backend/
npm install
npm run dev // to use nodemon with dotenv
// will start backend on http://localhost:8000
NOTE: If running dev, you will want to create a .env file to add your environment variables, TOKEN_SECRET, MONGO_URI
For frontend (which is served by express static in nodejs)
cd frontent/
npm install
npm start
// will server static frontend on http://localhost:3000
| Package | |
| Description | |
| Node Version | ~ 8.0.0 |
This Project follows the StandardJS style guide.
To Contribute:
- Clone Repo
npm install- Write Code
- Write Test(s)
- Submit Pull Request
_api-driven-demo is available under the MIT license.