Giter Site home page Giter Site logo

aws-serverless's Introduction

aws-serverless

Overview

  • Knexjs schema and migrations (models for user and device).
  • CRUD actions on the device table with aws Lambda
  • nextjs app with pages to view, and create devices.
  • authentication with cognito- iot simulation service
  • realtime data for the device in nextjs app.
  • lambda functions for: authorization, creating a device, getting a device by specified user, and a function that showcases getting data from IoT but doesn't do anything with it.

Basic Install and Run

This doc assumes you have node(npm, npx) installed.

Clone the repository and do the following:

cd nextjs
npm i
npm run dev

go to localhost:3000 to view the app.

IoT Demo

Node service in iotmock/ simulates a device and realtime values can be seen on the device page in webapp. Steps to demo:

  • run webapp
cd nextjs
npm i
npm run dev
  • go to localhost:3000/

  • click on Devices or login in navbar

  • login or create an account

  • create a new device and note down its name

  • unzip the provided ceritificates folder in iotmock directory such that the directory structure looks as following:

iotmock
├── certs
│   ├── private.pem.key
│   ├── public.pem.key
│   ├── root-ca.pem
│   └── thing-certificate.pem.crt
├── index.js
├── package.json
  • run node service with specific name of your device as argument
cd iotmock
npm run start --name <device-name>
  • while this process is running, go to the dashboard and click on device with the given name.

  • the device values should be updating realtime and will stop once the iotmock service is ended.

  • iotmock service uses device1 as default device name and its values are also recieved by the dashboard. if dashboard device's name does not match the name of the iotmock device, real time values don't show up but can still be viewed in the browser console.

Sections

Each section of the project is divided in apt directories:

iotmock:

Contains a node service that mocks an iot device. Steps to do so include:

cd iotmock
npm i
npm run start

You can specify the name of the device that you want to mock with --name option:

npm run start --name <device-name>

nextjs

Consists of the frontend code for the web application. To run:

cd nextjs
npm i
npm run dev

It runs on local host 3000 port. If that port is occupied you can use npx next dev -p 8080 to run on a different port.

knexjs

Contains all the migrations to the database. The migrations can be recreated by:

cd knexjs
npm i 

change knexfile.js database credentials to your database's endpoints. and then:

npx knex migrate:latest --knexfile db/knexfile.js

Migrations won't work on the default database since the RDS's network rule have been set such that they only allows certain ip address to run the migrations from.

serverless

Contains all the lambda functions deployed with serverless framework. To deploy functions to personal AWS

npm i
npm i -g serverless
serverless login
serverless deploy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.