1.2.0 • Published 7 years ago

http2cdn v1.2.0

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
7 years ago

http2cdn 🏵

CDN management service for http2server/http2live.

Usage

http2cdn <configuration>

Where <configuration> is the path to a file containing the configuration options. It can be JavaScript or JSON.

Configuration

Example: cdn.conf.js

const {tmpdir} = require('os')
const {join} = require('path')

module.exports = {
  // Top level domain for automatically generated subdomains
  wildcard: 'http2.live',

  // Directory where uploaded files will be stored before processing
  upload: tmpdir(),

  // Directory where public files will be stored
  public: join(process.cwd(), 'uploads'),

  // PostgreSQL connection string
  DATABASE_URL: 'postgres://seb@localhost/http2live',

  // Base configuration JSON file for http2server
  file: join(process.cwd(), 'http2server.conf.json'),

  // Runtime of http2server
  bin: join(process.cwd(), 'node_modules/.bin/http2server'),

  // Authentication details provided by Auth0
  jwt: {
    jwksUri: 'https://http2.au.auth0.com/.well-known/jwks.json',
    audience: 'https://http2.live/',
    issuer: 'https://http2.au.auth0.com/'
  },

  // Port to accept incoming connections
  port: 8888,

  // TLS credentials
  crypto: {
    key: join(process.cwd(), 'some.key.pem'),
    cert: join(process.cwd(), 'some.cert.pem'),
    ca: [
      join(process.cwd(), 'some.ca.pem'),
      join(process.cwd(), 'another.ca.pem')
    ]
  }
}

API

GET /

Shows a dummy index.html upload form. Broken at the moment. Use http2live instead.

POST /upload

Receives uploaded directory of static files and server host configuration.

Returns 200 upon success with a JSON object containing the published domain.

{"domain":"awesome-flying-tiger.http2.live"}

Errors are shown as 421.

Field directory

Upload one or more files with the same field name. The filename may contain a relative path, as per the webkitdirectory attribute.

Field options

JSON object containing valid http2configuration settings. The first host is associated with the deployed directory. Any other hosts are ignored.