Skip to content

Latest commit

 

History

History
93 lines (75 loc) · 2.6 KB

BareServer.md

File metadata and controls

93 lines (75 loc) · 2.6 KB

Bare Server

The TompHTTP Bare Server is a server that will receive requests from a service worker (or any client) and forward a request to the specified URL.

Bare Servers can run on directories. For example, if the directory was /bare/ then the bare origin would look like http://example.org/bare/. The bare origin is passed to clients.

Considerations when running an implementation under NGINX, Apache2, or Lighttpd

Due to the nature of header values being large, you must configure your web server to allow these large headers.

NGINX:

server {
	# ...
	# Upgrade WebSockets
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection 'Upgrade';
	# Increase header buffer
	proxy_connect_timeout 10;
	proxy_send_timeout 90;
	proxy_read_timeout 90;
	proxy_buffer_size 128k;
	proxy_buffers 4 256k;
	proxy_busy_buffers_size 256k;
	proxy_temp_file_write_size 256k;
	# proxy_pass http://localhost:8001;
	# ...
}

Request server info

Method Endpoint
GET /

This endpoint is not subject to change. It will remain the same across versions.

Response Headers:

Content-Type: application/json

Response Body:

{
  "versions": ["v1", "v2"],
  "language": "NodeJS",
  "memoryUsage": 1.04,
  "maintainer": {
    "email": "[email protected]",
    "website": "https://projects.example.org/"
  },
  "project": {
    "name": "Project",
    "description": "Unique TOMP implementation",
    "email": "[email protected]",
    "website": "https://git.example.org/",
    "repository": "https://git.example.org/dev/project.git",
    "version": "1.0.0"
  }
}

A ? after the property indicates it's optional.

  • maintainer {Object}?
    • email {String}?
    • website {String}?
  • project {Object}?: The project's information.
    • name {String}?
    • description {String}?
    • email {String}?
    • website {String}?
    • repository {String}?: A link to the project's .git file.
    • version {String}?: The semver version number of this project's backend.
  • versions {Array{String}}: A list of version names this server supports. (resolvable to http://server/versionName/)
  • language {String{NodeJS,Deno,Bun,ServiceWorker,Java,PHP,Rust,C,C++,C#,Ruby,Go,Crystal,Shell}}: The runtime. "language" is kept for legacy purposes.
  • memoryUsage {Number}?: The memory used by the server in base MB.

In NodeJS, memoryUsage should be calculated by:

Math.round((process.memoryUsage().heapUsed / 1024 / 1024) * 100) / 100;