A progressive Node.js framework for building efficient and scalable server-side applications.
IOT APP This is a basic implementation of an iot message broker using MQTT and GraphQL Nest framework TypeScript starter repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
The request and response data are stored in memory in a mock database. When a request is made the publisher publishes the request then the subscriber writes the request to a mock database.
- Node.js - Javascript runtime
- NestJs- Server-side Framework
- ApolloGraphQl - GraphQL Communication Layer
- MQTT - NPM MQTT package
- Mosquitto - MQTT Broker
http://localhost:3000/graphql
To send a message to mqtt broker
Mutation
mutation addMessage ($newMessageData: MessageInput!) {
addMessage (newMessageData: $newMessageData) {
title,
description
}
}
Pass the Query Variables as follows
{
"newMessageData": {
"id": "124",
"title": "dim4 sample",
"description":"sample description"
}
}
Query
query message {
message(id: "124") {
title
}
}
Query to get all messages and limit number of response NOTE passing limit:0 would return all messages limit: 10 returns 10 messages
query allMessages {
allMessages(limit: 0) {
title
}
}
- Setup a database connection and log messages from publisher to DB
- Write unit/integration tests
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Pascal Ulor
- Website - https://www.pascalulor.com/
Nest is MIT licensed.