diff --git a/docs/api.md b/docs/api.md
deleted file mode 100644
index 97c4c61..0000000
--- a/docs/api.md
+++ /dev/null
@@ -1,140 +0,0 @@
-# Authentication
-
-Some API methods require an authentication token. This token is a [JSON web token](https://en.wikipedia.org/wiki/JSON_Web_Token) that contains a list of "scopes" (i.e. permissions).
-
-Once you obtain an API token ([see below](#post-api-auth)) you simply include it in the `Authorization` header of your request as a base-64 encoded string, i.e.
-
-```
-Authorization: base64(token)
-```
-
-### GET /api/publicKey
-
-The [public key](https://en.wikipedia.org/wiki/Public-key_cryptography) unpkg uses to encrypt authentication tokens, as JSON. You can also find the key as plain text [on GitHub](https://github.com/unpkg/unpkg.com/blob/master/secret_key.pub).
-
-This can be useful to verify a token was issued by unpkg.
-
-Required scope: none
-
-Query parameters: none
-
-Example:
-
-```log
-> curl "https://unpkg.com/api/publicKey"
-{
- "publicKey": "..."
-}
-```
-
-### POST /api/auth
-
-Creates and returns a new auth token. By default, auth tokens have the following scopes:
-
-```json
-{
- "blacklist": {
- "read": true
- }
-}
-```
-
-Required scope: none
-
-Body parameters: none
-
-Example:
-
-```log
-> curl -X POST "https://unpkg.com/api/auth"
-{
- "token": "..."
-}
-```
-
-Please reach out to @mjackson if you need a token with additional scopes.
-
-### GET /api/auth
-
-Verifies and returns the payload contained in the given auth token.
-
-Required scope: none
-
-Query parameters: none
-
-Example:
-
-```log
-> curl -H "Authorization: $BASE_64_ENCODED_TOKEN" "https://unpkg.com/api/auth"
-{
- "jti": "...",
- "iss": "https://unpkg.com",
- "iat": ...,
- "scopes": { ... }
-}
-```
-
-# Blacklist
-
-To protect unpkg users and prevent abuse, unpkg manages a blacklist of npm packages that are known to contain harmful code.
-
-### GET /api/blacklist
-
-Returns a list of all packages that are currently blacklisted.
-
-Required scope: `blacklist.read`
-
-Query parameters: none
-
-Example:
-
-```log
-> curl -H "Authorization: $BASE_64_ENCODED_TOKEN" "https://unpkg.com/api/blacklist"
-{
- "blacklist": [ ... ]
-}
-```
-
-### POST /api/blacklist
-
-Adds a package to the blacklist.
-
-Required scope: `blacklist.add`
-
-Body parameters:
-
-* `packageName` - The package to add to the blacklist (required)
-
-Example:
-
-```log
-> curl -H "Authorization: $BASE_64_ENCODED_TOKEN" -d '{"packageName":"bad-package"}' "https://unpkg.com/api/blacklist"
-{
- "ok": true
-}
-```
-
-### DELETE /api/blacklist
-
-Removes a package from the blacklist.
-
-Required scope: `blacklist.remove`
-
-Body parameters:
-
-* `packageName` - The package to remove from the blacklist (required)
-
-Example:
-
-```log
-> curl -X DELETE -H "Authorization: $BASE_64_ENCODED_TOKEN" -d '{"packageName":"bad-package"}' "https://unpkg.com/api/blacklist"
-{
- "ok": true
-}
-```
-
-# Stats
-
-### GET /api/stats
-
-TODO
diff --git a/docs/cloudflare-logo.png b/docs/cloudflare-logo.png
deleted file mode 100644
index 52f2820..0000000
Binary files a/docs/cloudflare-logo.png and /dev/null differ
diff --git a/docs/heroku-logo.png b/docs/heroku-logo.png
deleted file mode 100644
index cdc5379..0000000
Binary files a/docs/heroku-logo.png and /dev/null differ
diff --git a/docs/home.md b/docs/home.md
deleted file mode 100644
index 4af3ba2..0000000
--- a/docs/home.md
+++ /dev/null
@@ -1,48 +0,0 @@
-unpkg is a fast, global [content delivery network](https://en.wikipedia.org/wiki/Content_delivery_network) for everything on [npm](https://www.npmjs.com/). Use it to quickly and easily load any file from any package using a URL like:
-
-
unpkg.com/:package@:version/:file
-
-### Examples
-
-Using a fixed version:
-
- * [unpkg.com/react@16.0.0/umd/react.production.min.js](/react@16.0.0/umd/react.production.min.js)
- * [unpkg.com/react-dom@16.0.0/umd/react-dom.production.min.js](/react-dom@16.0.0/umd/react-dom.production.min.js)
-
-You may also use a [semver range](https://docs.npmjs.com/misc/semver) or a [tag](https://docs.npmjs.com/cli/dist-tag) instead of a fixed version number, or omit the version/tag entirely to use the `latest` tag.
-
- * [unpkg.com/react@^16/umd/react.production.min.js](/react@^16/umd/react.production.min.js)
- * [unpkg.com/react/umd/react.production.min.js](/react/umd/react.production.min.js)
-
-If you omit the file path (i.e. use a "bare" URL), unpkg will serve the file specified by the `unpkg` field in `package.json`, or fall back to `main`.
-
- * [unpkg.com/d3](/d3)
- * [unpkg.com/jquery](/jquery)
- * [unpkg.com/three](/three)
-
-Append a `/` at the end of a URL to view a listing of all the files in a package.
-
- * [unpkg.com/react/](/react/)
- * [unpkg.com/lodash/](/lodash/)
-
-### Query Parameters
-
-
-
`?meta`
-
Return metadata about any file in a package as JSON (e.g. `/any/file?meta`)
-
-
`?module`
-
Expands all ["bare" `import` specifiers](https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier) in JavaScript modules to unpkg URLs. This feature is *very experimental*
-
-
-### Workflow
-
-For npm package authors, unpkg relieves the burden of publishing your code to a CDN in addition to the npm registry. All you need to do is include your [UMD](https://github.com/umdjs/umd) build in your npm package (not your repo, that's different!).
-
-You can do this easily using the following setup:
-
- * Add the `umd` (or `dist`) directory to your `.gitignore` file
- * Add the `umd` directory to your [files array](https://docs.npmjs.com/files/package.json#files) in `package.json`
- * Use a build script to generate your UMD build in the `umd` directory when you publish
-
-That's it! Now when you `npm publish` you'll have a version available on unpkg as well.
diff --git a/modules/actions/serveMainPage.js b/modules/actions/serveMainPage.js
index b0c2ab1..f569ddd 100644
--- a/modules/actions/serveMainPage.js
+++ b/modules/actions/serveMainPage.js
@@ -1,6 +1,5 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
-import { StaticRouter } from 'react-router-dom';
import MainTemplate from '../client/MainTemplate';
import MainApp from '../client/main/App';
@@ -9,12 +8,9 @@ import getEntryPoints from '../utils/getEntryPoints';
import renderTemplate from '../utils/renderTemplate';
export default function serveMainPage(req, res) {
- const element = React.createElement(
- StaticRouter,
- { location: req.url },
- React.createElement(MainApp)
+ const content = createHTML(
+ ReactDOMServer.renderToString(React.createElement(MainApp))
);
- const content = createHTML(ReactDOMServer.renderToString(element));
const entryPoints = getEntryPoints('main', {
es: 'module',
diff --git a/modules/client/main.js b/modules/client/main.js
index 34fcbc0..3f32a5d 100644
--- a/modules/client/main.js
+++ b/modules/client/main.js
@@ -1,6 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { HashRouter } from 'react-router-dom';
import { Global, css } from '@emotion/core';
import App from './main/App';
@@ -72,11 +71,9 @@ const globalStyles = css`
`;
ReactDOM.render(
-
-
- The CDN caches files based on their permanent URL, which includes the
- npm package version. This works because npm does not allow package
- authors to overwrite a package that has already been published with a
- different one at the same version number.
-
-
- URLs that do not specify a package version number redirect to one that
- does. This is the latest version when no version is
- specified, or the maxSatisfying version when a{' '}
- semver version is
- given. Redirects are cached for 5 minutes.
-
-
- Browsers are instructed (via the Cache-Control header) to
- cache assets for 1 year.
-
-
-
Abuse
-
- unpkg maintains a list of packages that are known to be malicious. If
- you find such a package on npm, please let us know!
-
-
-
Support
-
- unpkg is not affiliated with or supported by npm, Inc. in any way.
- Please do not contact npm for help with unpkg. Instead, please reach out
- to @unpkg with any questions or
- concerns.
-
-
- );
-}
diff --git a/modules/client/main/App.js b/modules/client/main/App.js
index a5579f0..d608050 100644
--- a/modules/client/main/App.js
+++ b/modules/client/main/App.js
@@ -1,12 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { Switch, Route, Link, withRouter } from 'react-router-dom';
-import { Motion, spring } from 'react-motion';
+import formatBytes from 'pretty-bytes';
+import formatDate from 'date-fns/format';
+import parseDate from 'date-fns/parse';
-import WindowSize from './WindowSize';
-import About from './About';
-import Stats from './Stats';
-import Home from './Home';
+import formatNumber from '../utils/formatNumber';
+import formatPercent from '../utils/formatPercent';
+
+import cloudflareLogo from './CloudflareLogo.png';
+import herokuLogo from './HerokuLogo.png';
const styles = {
title: {
@@ -40,44 +42,60 @@ const styles = {
backgroundColor: 'black',
position: 'absolute',
left: 0
+ },
+ example: {
+ textAlign: 'center',
+ backgroundColor: '#eee',
+ margin: '2em 0',
+ padding: '5px 0'
+ },
+ logoList: {
+ margin: '2em 0',
+ display: 'flex',
+ justifyContent: 'center'
+ },
+ logo: {
+ textAlign: 'center',
+ flex: '1',
+ maxWidth: '80%'
+ },
+ logoImage: {
+ maxWidth: '60%'
}
};
-class Layout extends React.Component {
- state = {
- underlineLeft: 0,
- underlineWidth: 0,
- useSpring: false,
- stats: null
- };
+function AboutLogo({ children }) {
+ return
+ From {formatDate(since, 'MMM D')} to{' '}
+ {formatDate(until, 'MMM D')} unpkg served{' '}
+ {formatNumber(totals.requests.all)} requests and a total
+ of {formatBytes(totals.bandwidth.all)} of data to{' '}
+ {formatNumber(totals.uniques.all)} unique visitors,{' '}
+
+ {formatPercent(totals.requests.cached / totals.requests.all, 0)}%
+ {' '}
+ of which were served from the cache.
+
+ unpkg is a fast, global{' '}
+
+ content delivery network
+ {' '}
+ for everything on npm. Use it
+ to quickly and easily load any file from any package using a URL
+ like:
+
+ You may also use a{' '}
+ semver range or a{' '}
+ tag instead of a
+ fixed version number, or omit the version/tag entirely to use the{' '}
+ latest tag.
+
+ If you omit the file path (i.e. use a “bare” URL), unpkg
+ will serve the file specified by the unpkg field in{' '}
+ package.json, or fall back to
+ main.
+
+ Return metadata about any file in a package as JSON (e.g.
+ /any/file?meta)
+
+
+
+ ?module
+
+
+ Expands all{' '}
+
+ “bare” import specifiers
+ {' '}
+ in JavaScript modules to unpkg URLs. This feature is{' '}
+ very experimental
+
+
+
+
Cache Behavior
+
+
+ The CDN caches files based on their permanent URL, which includes the
+ npm package version. This works because npm does not allow package
+ authors to overwrite a package that has already been published with a
+ different one at the same version number.
+
+
+ URLs that do not specify a package version number redirect to one that
+ does. This is the latest version when no version is
+ specified, or the maxSatisfying version when a{' '}
+ semver version is
+ given. Redirects are cached for 5 minutes.
+
+
+ Browsers are instructed (via the Cache-Control header) to
+ cache assets for 1 year.
+
+
+
About
+
+
+ unpkg is an open source project
+ built and maintained by{' '}
+ Michael Jackson. unpkg is
+ not affiliated with or supported by npm, Inc. in any way. Please do
+ not contact npm for help with unpkg. Instead, please reach out to{' '}
+ @unpkg with any questions or
+ concerns.
+
+
+
+ The fast, global infrastructure that powers unpkg is generously
+ donated by Cloudflare and{' '}
+ Heroku.
+
+ For npm package authors, unpkg relieves the burden of publishing your
+ code to a CDN in addition to the npm registry. All you need to do is
+ include your UMD build in
+ your npm package (not your repo, that's different!).
+
+
+
You can do this easily using the following setup:
+
+
+
+ Add the umd (or dist) directory to your{' '}
+ .gitignore file
+
+
+ Add the umd directory to your{' '}
+
+ files array
+ {' '}
+ in
+ package.json
+
+
+ Use a build script to generate your UMD build in the{' '}
+ umd directory when you publish
+
+
+
+
+ That's it! Now when you npm publish you'll have
+ a version available on unpkg as well.
+
- unpkg is a fast, global{' '}
-
- content delivery network
- {' '}
- for everything on npm. Use it to
- quickly and easily load any file from any package using a URL like:
-
- You may also use a{' '}
- semver range or a{' '}
- tag instead of a fixed
- version number, or omit the version/tag entirely to use the{' '}
- latest tag.
-
- If you omit the file path (i.e. use a “bare” URL), unpkg
- will serve the file specified by the unpkg field in{' '}
- package.json, or fall back to
- main.
-
- Return metadata about any file in a package as JSON (e.g.
- /any/file?meta)
-
-
-
- ?module
-
-
- Expands all{' '}
-
- “bare” import specifiers
-
- in JavaScript modules to unpkg URLs. This feature is{' '}
- very experimental
-
-
-
-
Workflow
-
-
- For npm package authors, unpkg relieves the burden of publishing your
- code to a CDN in addition to the npm registry. All you need to do is
- include your UMD build in
- your npm package (not your repo, that's different!).
-
-
-
You can do this easily using the following setup:
-
-
-
- Add the umd (or dist) directory to your{' '}
- .gitignore file
-
-
- Add the umd directory to your{' '}
-
- files array
- {' '}
- in
- package.json
-
-
- Use a build script to generate your UMD build in the umd{' '}
- directory when you publish
-
-
-
-
- That's it! Now when you npm publish you'll have a
- version available on unpkg as well.
-
- From {formatDate(since, 'MMM D')} to{' '}
- {formatDate(until, 'MMM D')} unpkg served{' '}
- {formatNumber(totals.requests.all)} requests and a
- total of {formatBytes(totals.bandwidth.all)} of data
- to {formatNumber(totals.uniques.all)} unique
- visitors,{' '}
-
- {formatPercent(totals.requests.cached / totals.requests.all, 0)}%
- {' '}
- of which were served from the cache.
-
-
-
Packages
-
-
- We recently migrated unpkg to a new backend and are working on getting
- package-specific data back on the site.
-
-
- {/*
-
- The table below shows the most popular packages served by unpkg from{' '}
- {formatDate(since, 'MMM D')} to{' '}
- {formatDate(until, 'MMM D')}. Only the top{' '}
- {Object.keys(totals.requests.package).length} packages are shown.
-
-
-
- Include only packages that received at least{' '}
- {' '}
- requests.
-
-
-
-
-
-
- Package
-
-
- Requests (% of total)
-
-
- Bandwidth (% of total)
-
-
-
- {packageRows}
-
- */}
-
-
Regions
-
-
- The table below breaks down requests to unpkg from{' '}
- {formatDate(since, 'MMM D')} to{' '}
- {formatDate(until, 'MMM D')} by geographic region.
-
-
-
- Include only countries that made at least{' '}
- {' '}
- requests.
-
-
-
-
-
-
- Region
-
-
- Requests (% of total)
-
-
- Bandwidth (% of total)
-
-
-
- {regionRows}
-
-
- {/*
-
Protocols
-
-
- The table below breaks down requests to unpkg from{' '}
- {formatDate(since, 'MMM D')} to{' '}
- {formatDate(until, 'MMM D')} by HTTP protocol.
-