Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aliartiza75/crud-for-iot-devices

This repository holds CRUD for IoT device using express framework.
https://github.com/aliartiza75/crud-for-iot-devices

ci docker nodejs travis-ci

Last synced: 26 days ago
JSON representation

This repository holds CRUD for IoT device using express framework.

Awesome Lists containing this project

README

        

# IoT Device CRUD

## Overview

This repository holds the manifests for the API of the IoT Device CRUD.

## Folder Structure

```bash
├── app.js # configuration for server
├── bin
│   └── server-start # server starting component
├── controllers # controllers handles the user requests
│   ├── AuthController.js
│   ├── DeviceController.js
│   └── FeedController.js
├── helpers # helpers are used in controllers
│   ├── apiResponse.js
│   └── utility.js
├── middlewares # intercepts the requests and validate jwt token
│   └── jwt.js
├── models # models
│   ├── DeviceModel.js
│   ├── FeedModel.js
│   └── UserModel.js
├── mqtt-python-client # mqtt clients
│   ├── configure_env.sh
│   ├── consumer.py
│   ├── producer.py
│   ├── README.md
│   └── requirements.txt
├── package.json # packages information
├── package-lock.json
├── postman-collection # collection of api endpoints
│   └── api.json
├── README.md # documentation
└── routes # api routes
├── api.js
├── auth.js
├── device.js
├── feed.js
└── index.js
```

## Deployment Guidelines

Following the guidelines to start the server:

1. Install node and npm.

2. Install packages

```bash
npm install
```

3. Convert the `.env.example` to `.env` file because server use the configuration provided in this file.

4. Start mongodb server as a docker container:

```bash
sudo docker run -d \
-e MONGO_INITDB_ROOT_USERNAME=mongoadmin \
-e MONGO_INITDB_ROOT_PASSWORD=secret \
-p 27017:27017 \
mongo
```

5. Run the lint to check any linting issue:

```bash
npm run lint
```

6. To start the server:

```bash
npm run dev
```

7. Running as Docker container

1. Build its image:

```bash
sudo docker build -t crud-for-iot-devices:0.0.1 -f build/package/Dockerfile .
```

2. Run it as a container:

```bash
sudo docker run -it -e MONGODB_URL=mongodb://127.0.0.1:27017/crud-for-iot-devices -e JWT_SECRET=abc1235 -e JWT_TIMEOUT_DURATION="2 hours" --net host crud-for-iot-devices:0.0.1
```

8. Import the postman collection in the Postman application to use the api endpoints.