This sample project is managing gateways - master devices that control multiple peripheral devices
A simple REST service (JSON/HTTP) for storing information about gateways and their associated devices with a Basic UI to list and manage gateway devices. All information is stored in Mongo database.
- Clone this repo
git clone https://github.com/aymanaladdin/gateway-manager.git
- After clonning successfully switch to cloned repo dir and install deps
cd ./gateway-namager && npm run install:all
- create an
.env
file toserver
sub dir, you can replace values with your own specially mongo URI
PORT=5000
NODE_ENV=development
MONGO_URI=mongodb://localhost:27017/gateway-manager
- create an
.env
file toclient
sub dir, you can replace values with your own
REACT_APP_API_URL = http://localhost:5000/api/v1
- if you have a docker installed with docker-compose you could start the mongo container in
docker-compose.yaml
file via
docker-compose up -d mongo
- To init start mongo with seeded data run the following cmd, this will create a collection with seeded data
docker-compose up -d mongodb mongo-seed
- if you don't have installed docker you should download a mongo client first and start it manually
- you could still able to seed data manually as well, open mongo shell from terminal and run the following cmd
mongoimport --host localhost --port 27017 --db gateway-manager --collection gateways --mode upsert --type json --file /data/seeding/gateways.json --jsonArray
- to start app in development mode run the following cmd from root dir
npm run dev
- this will start
client:react
app in development which you can access by default viahttp:localhost:3000
- also it will start
server:express
app in development which you can access by default viahttp:localhost:5000
- Run the following command to run a bundled version of the app altogether
npm run start
- this command will build
client:react
andserver:express
apps and serve them from a single app by defaulthttp:localhost:5000
- Run the following command to run a bundled version of the app altogether
npm run docker:start
- this command will build both
client:react
andserver:express
apps, then start a docker container for the bundled app by defaulthttp:localhost:5000
- Make sure that you have a mongo client up and running otherwise the
server:express
app will fail to start, you can start it manually or via docker as described inDB Starting section
- Make sure that you added
.env
files in both./server
and./client
sub dirs otherwise processes will fail while starting
- you can use
npm run dev:client
to runclient:react
app only - you can use
npm run dev:server
to runserver:express
app only - you can use
npm run build:client
to buildclient:react
app and push the built files toserver:express
docs sub dir
This project is licensed under the [MIT] License