npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iotjs-express

v0.0.22

Published

Basic reimplementation of Express.js for IoT.js or Node

Downloads

133

Readme

IOTJS-EXPRESS

GitHub forks license Build Status NPM JsDelivr IRC Channel Docker Pulls Automated Builds Build Status codebeat badge Codacy Badge CII Best Practices Fediverse

NPM

INTRODUCTION

While ExpressJs claims to be minimalist, many dependencies are required and thus can't support IoT.js runtime (powered by JerryScript an alternative engine for MicroControllers).

Instead of porting the whole project to older ECMA standards, basic routing was re-implemented, and API tried to be preserved.

Originally this module was done for "webthing-iotjs" project, a library to build webthings to connect to WebThingsIo gateway.

Source file was bundled into project, but then pulled out as this standalone module, which can be used by both runtime Node.Js and IoT.js.

Presentation

USAGE WITH IOTJS

mkdir iotjs_modules
git clone https://github.com/rzr/iotjs-express iotjs_modules/iotjs-express
cd iotjs_modules/iotjs-express
make start &
#| iotjs example

curl -i http://localhost:8080/.well-known/security.txt
#| HTTP/1.1 200 OK
#| access-control-allow-origin: *
#| access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept
#| access-control-allow-methods: GET, HEAD, PUT, POST, DELETE
#|
#| Contact: https://www.npmjs.com/~rzr

curl -i http://localhost:8080/favicon.ico
#| HTTP/1.1 404 Not Found
#| content-length: 23
#| Error: 404 (Not Found)

curl -i http://localhost:8080/~rzr
#| {"user":"rzr"}

curl -X PUT -d '{"value":42}' http://localhost:8080/db/some-key
#| {"some-key":42}

curl -X PUT -d '{"value":1984}' http://localhost:8080/db/some-other-key
#| {"some-key":42,"some-other-key":1984}

curl -i  http://localhost:8080/static/README.md
#| HTTP/1.1 200 OK
#| # IOTJS-EXPRESS #
#| (...)

iotjs_modules

USAGE WITH NODE

It's mostly the same:

npm install iotjs_express
cd node_modules/iotjs-express
npm start
# Or:
make start runtime=node
#| node example

USAGE WITH DOCKER

docker run --net host rzrfreefr/iotjs-express:latest
curl http://localhost:8080/.well-known/security.txt
#| Contact: https://www.npmjs.com/~rzr

# Or from sources
docker-compose up
curl http://localhost:8080/.well-known/security.txt
#| Contact: https://www.npmjs.com/~rzr

USAGE WITH MINIKUBE


name="iotjs-express"
url="https://raw.githubusercontent.com/rzr/iotjs-express/master/extra/tools/kube/$name.yml"
url=https://raw.githubusercontent.com/rzr/iotjs-express/sandbox/rzr/devel/master/extra/tools/kube/$name.yml
kubectl=kubectl

minikube version

minikube start || minikube logs --alsologtostderr

$kubectl version

$kubectl apply -f "${url}"
#| deployment.extensions/iotjs-express created
#| service/iotjs-express created

time minikube service ${name} --url
#| http://192.168.99.102:30080
time minikube service ${name}
#| 🎉  Opening kubernetes service default/iotjs-express in default browser...

USAGE WITH K3S

project="iotjs-express"
image="rzrfreefr/${project}:latest"
kubectl="sudo kubectl"

sudo sync
sudo snap remove microk8s
curl -sfL https://get.k3s.io | sh - # v0.7.0
sudo systemctl restart k3s.service || sudo systemctl status k3s.service

$kubectl get nodes # Wait "Ready state"
#| {host}   NotReady   master   5s    v1.14.4-k3s.1
#| (...)
#| {host}   Ready    master   51s   v1.14.4-k3s.1

$kubectl run "${project}" --image="${image}"

$kubectl get all --all-namespaces | grep "$project"
#| default       pod/iotjs-express-...-...   1/1     Running     0          ..s

pod=$($kubectl get all --all-namespaces \
  | grep -o "pod/${project}.*" | cut -d/ -f2 | awk '{ print $1}' \
  || echo failure) && echo pod="$pod"
$kubectl describe pod "$pod"  | grep 'Status:             Running'
ip=$($kubectl describe pod "$pod" | grep 'IP:' | awk '{ print $2 }') && echo "ip=${ip}"

curl http://$ip:8080/.well-known/security.txt

DEMO

In "webthing-iotjs-20180621rzr" video, Edison's running a webthing server powered by iotjs-express framework to build routes, (it relies on IoT.js's http module, API is aligned to node)

webthing-iotjs-20180621rzr

Demo also shows following systems:

  • Edison: iotjs-express + webthing-iotjs on Jubilinux (Debian fork).
  • RaspberryPi: webthings-gateway + express.js on Raspbian
  • Galaxy note: SamsungInternet web browser for Android.

EXTRA EXAMPLES

iotjs example/client.js 8080 localhost /.well-known/security.txt
Contact: https://www.npmjs.com/~rzr

An extra example is added to show how to make a bridge from HTTP/REST to MQTT.

RESOURCES