Coder Social home page Coder Social logo

influxdata / iot-api-ui Goto Github PK

View Code? Open in Web Editor NEW
13.0 9.0 2.0 223 KB

Common React UI for iot-api-<js, python, etc.> example apps designed for InfluxDB client library tutorials.

License: MIT License

JavaScript 2.57% TypeScript 84.35% CSS 13.08%
data-visualization influxdata influxdb influxdb-js-client influxdb-python nextjs react visualization

iot-api-ui's Introduction

Common UI for iot-api tutorials.

This is a Next.js project bootstrapped with create-next-app and customized to route /api requests to external middleware - specifically, the InfluxData iot-app-<js, python, etc.> example applications.

Start the Next.js frontend app

  1. Run the development server:

    npm run dev
    # or
    yarn dev
  2. Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.

Use with iot-api-[language] apps

To use the UI with one of the iot-api-[language] example apps, set API_URL in ./.env.development to the URL of the API example app.

iot-api-ui uses a Next.js catch-all route and http-proxy to proxy all /api requests to your API middleware server. See ./pages/api/[...path].js for the /api route and proxy configuration.

import httpProxy from 'http-proxy'

/** Set API_URL to the URL of iot-api-js, iot-api-python, etc. **/
const API_URL = process.env.API_URL
const proxy = httpProxy.createProxyServer()
/** Don't parse JSON bodies on the proxied route **/
export const config = {
    api: {
        bodyParser: false
    }
}
export default (req, res) => {
    proxy.web(req, res, { target: API_URL, changeOrigin: true })
}

Learn More

To learn more about Next.js, see following resources:

Credits

  1. https://maxschmitt.me/posts/next-js-api-proxy/ for the http-proxy configuration.

iot-api-ui's People

Contributors

dependabot[bot] avatar jdstrand avatar jdstrand-dontuse avatar jstirnaman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.