All Projects → rumkin → Plant

rumkin / Plant

Licence: other
🌳 JS web server charged with WebAPI and neat HTTP2 support

Programming Languages

javascript
184084 projects - #8 most used programming language
js
455 projects

Projects that are alternatives of or similar to Plant

Sqlservermetadata
SQL Server Metadata Toolkit
Stars: ✭ 47 (-20.34%)
Mutual labels:  server
Api server boilerplate
typescript express board boilerplate using routing controller
Stars: ✭ 52 (-11.86%)
Mutual labels:  server
Nitro
A discord bot
Stars: ✭ 56 (-5.08%)
Mutual labels:  server
Freeflix
Freeflix is a streaming server that integrates a BitTorrent client.
Stars: ✭ 48 (-18.64%)
Mutual labels:  server
Saltyrtc Server Python
SaltyRTC signalling server implementation.
Stars: ✭ 50 (-15.25%)
Mutual labels:  server
Phpwpinfo
Provides an equivalent to the `phpinfo()` but with more WordPress requirements details.
Stars: ✭ 52 (-11.86%)
Mutual labels:  server
Ecoleta
Projecto construído durante o Next Level Week 1 - Ecoleta by @Rocketseat
Stars: ✭ 46 (-22.03%)
Mutual labels:  server
Hedwig
Send email to any SMTP server like a boss, in Swift and cross-platform
Stars: ✭ 1,096 (+1757.63%)
Mutual labels:  server
Bankai
🚉 - friendly web compiler
Stars: ✭ 1,064 (+1703.39%)
Mutual labels:  server
Dragon
⚡A powerful HTTP router and URL matcher for building Deno web servers.
Stars: ✭ 56 (-5.08%)
Mutual labels:  server
Racingworld
💥 A multiplayer online 3D game about racing 💥
Stars: ✭ 50 (-15.25%)
Mutual labels:  server
Cti Taxii Server
OASIS TC Open Repository: TAXII 2 Server Library Written in Python
Stars: ✭ 50 (-15.25%)
Mutual labels:  server
Server
Enterprise Open Source IM Solution
Stars: ✭ 53 (-10.17%)
Mutual labels:  server
Springsnail
《Linux 高性能服务器》附带的项目程序springsnil详细解读,一个负载均衡服务器
Stars: ✭ 47 (-20.34%)
Mutual labels:  server
Homeserver
A Matrix homeserver written in Rust.
Stars: ✭ 1,089 (+1745.76%)
Mutual labels:  server
Tox Node
A server application to run tox node written in pure Rust
Stars: ✭ 47 (-20.34%)
Mutual labels:  server
Sechub
SecHub - one central and easy way to use different security tools with one API/Client
Stars: ✭ 52 (-11.86%)
Mutual labels:  server
Rnl
RNL - Realtime Network Library - The opensource reliable UDP network library
Stars: ✭ 59 (+0%)
Mutual labels:  server
Gaia
C++ framework for rapid server development
Stars: ✭ 58 (-1.69%)
Mutual labels:  server
Subscriptions Transport Sse
A Server-Side-Events (SSE) client + server for GraphQL subscriptions
Stars: ✭ 55 (-6.78%)
Mutual labels:  server

Plant logo

Plant

npm npm

NPM · Source · Readme

Plant is WebAPI standards based HTTP2 web server, created with modular architecture and functional design in mind. Also it's pure and less coupled.

Plant supports HTTP 1 and HTTP 2 protocols. But it's transport agnostic and can work right in the browser over WebSockets, WebRTC, or PostMessage.

Features

  • ☁️ Lightweight: only 8 KiB minified and gzipped.
  • ✨ Serverless ready: works even in browser.
  • 🛡 Security oriented: uses the most strict Content Securiy Policy (CSP) by default.
  • 📐 Standards based: uses WebAPI interfaces.
  • 🛳 Transport agnostic: no HTTP or platform coupling, ship requests via everything.

Table of Contents

Install

# Install plant web server
npm i @plant/plant
# Install node HTTP2 transport
npm i @plant/http2

Examples

Hello World

Hello world with HTTP2 as transport.

⚠️ Note that default CSP header value is default-src localhost; form-action localhost. This will prevent web page from loading any external resource at all. Set minimal required CSP on your own. Read about CSP on Mozilla Developer Network

// Build request handler
const createServer = require('@plant/http2');
const Plant = require('@plant/plant');

const plant = new Plant();
plant.use(({res}) => {
  res.body = 'Hello, World!'
})

createServer(plant)
.listen(8080)

Router

Plant's builtin router is extremely simple and works only with exact strings. But there is more powerful router package which brings named params and regular expressions into routing.

const Plant = require('@plant/plant');
const Router = require('@plant/router');

const plant = new Plant()
const router = new Router()

router.get('/user/:name', async function({res, route}) {
  res.body = `Hello, ${route.params.name}!`
})

plant.use('/api/v1/*', router)

HTTP2 pushes

Hello world with HTTP2 as transport.

// Build request handler
const createServer = require('@plant/http2');
const Plant = require('@plant/plant');

const plant = new Plant();

plant.use('/script.js', ({res}) => {
  res.headers.set('content-type', 'application/javascript')
  res.body = 'console.log("Hello")'
})

plant.use('/index.html', ({res, fetch}) => {
  // Push '/script.js' URL to pushed resources.
  // It will be requested before sending main response.
  res.push('/script.js')
  // ... or ...
  // Push complete response from subrequest
  res.push(
    await fetch('/script.js')
  )

  res.body = '<html><script src="/script.js"></script></html>'
})

createServer(plant)
.listen(8080)

Packages

Router @plant/router

NPM · Source · Readme

Plant standalone router.

HTTP(S) Packages

HTTP2 @plant/http2

NPM · Source · Readme

Plant adapter for native node.js http2 module server. It creates server listener from Plant instance and http2.createServer() options. It's usage is the same as https module.

HTTPS2 @plant/https2

NPM · Source · Readme

Plant adapter for native node.js http2 module SSL server. It creates server listener from Plant instance and http2.createSecureServer() options. It's usage is the same as https module.

HTTP @plant/http

NPM · Source · Readme

Plant adapter for native node.js http module. It creates server listener from plant instance.

HTTPS @plant/https

NPM · Source · Readme

Plant adapter for native node.js https module. It creates server listener from plant instance and https options.

HTTP Adapter @plant/http-adapter

NPM · Source · Readme

This package is using to connect Plant and native Node's HTTP server. Modules http, https, http2, and https2 use it under the hood.

Electron Packages

Electron @plant/electron

NPM · Source · Readme

This package is using to connect Plant and with current Electron instance protocols API. It's using electron-adapter under the hood.

Electron Adapter @plant/electron-adapter

NPM · Source · Readme

This package is using to connect Plant and with Electron protocols API.

Utility Packages

Flow @plant/flow

NPM · Source · Readme

This is library for cascades. This is where contexts manage take place and requests pass from one handler to another.

Node Stream Utils @plant/node-stream-utils

NPM · Source · Readme

Node <-> WebAPI streams adapters. Useful for wrapping Node.js streams to work with Plant.

Tests Packages

Test HTTP Suite @plant/test-http

NPM · Source · Readme

Tiny package with tools for HTTP testing. It simplify server creation and request sending and receiving.

License

MIT © Rumkin

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].