Skip to content

Latest commit

History

History
52 lines (35 loc) 路 1.61 KB

readme_node-api.md

File metadata and controls

52 lines (35 loc) 路 1.61 KB

Node.js API & Github Enterprise

Github CDN offers a Node.js API so you can roll your own instance. You might want to do this to personalize it or configure it to use a Github Enterprise server.

馃殌 Quick setup

Install

$ npm i github-cdn

Add to Express

import express from 'express';
import cookieParser from 'cookie-parser';
import githubCdnRouter from 'github-cdn';

const app = express();

...

// For parsing the custom token
app.use(cookieParser());

app.use(githubCdnRouter());

...

app.listen(...);

Config

Github CDN points at the public Github by default, but you can configure it to point to a Github Enterprise, use memcached, or add a whitelist.

The configuration file is detected and read using cosmicconfig to support various config naming conventions (eg. .githubcdnrc.js, githubcdn.config.js).

Schema

  • github (Object)

    • base (String) - Github URL (default: https://github.com)
    • apiBase (String) - Github API URL (default: https://api.github.com)
    • token (String) - Github API token
  • landingPageMdSrc (String) - URL of a Markdown file to render on the landing page (default: Github CDN readme.md)

  • memcached (String) - Memcached host:port (eg. localhost:11211)

    Tip: Set a higher storage limit via memcached -I 10m

  • whitelist (Array<Object>) - Only allow access to specific repos

    • owner (String) - Owner of the repo to whitelist
    • repo (String) - Name of the repo to whitelist
    • gists (Boolean) - Whether the owner's Gists are accessible