A basic calculator application that allows:
- to add 2 number
- to perform this addition remotely through an API call
Using Node, Hapi and React.
This project was bootstrapped with [Create React App]
- Nodejs (>= v6)
- Nvm
- Hapi
- React
- Docker
You should change API_SERVER_HOST in src/config/config.js to your WAN or LAN address.
$ git clone https://github.com/ariel-zplinux/simple-calculator.git
$ cd simple-calculator
$ npm install
$ npm run server # API server on http://host:8000
Then, in a separate terminal.
For development mode:
$ npm start # Web server on http://host:3000
Or for production mode
$ npm run build
$ npm install serve -g
$ npm run prod # Web server on http://host:5000
Or with Docker
$ git clone https://github.com/ariel-zplinux/simple-calculator.git
$ cd simple-calculator
$ docker build -t "simple-calculator" .
$ docker run -p 5000:5000 -p 8000:8000 "simple-calculator"
-
Enter a first number
-
Enter +
-
Enter a second number
-
Enter =
Then it's possible to go on additionning numbers
C button resets the calculator
Command | Description |
---|---|
npm run server | Start API server @localhost:8000 |
npm start | Start web server in development mode @localhost:3000 |
npm run build | Prepare production mode |
npm run prod | Start web server in production mode @localhost:5000 |
npm install | Install dependencies |
HTTP Method | Url | Parameters | Description |
---|---|---|---|
GET | /addition | previous, current | Add previous and current |
- Hapi (API framework) - https://hapijs.com/
- Create-React-App (Facebook React Starter Kit) https://github.com/facebookincubator/create-react-app