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( - -
- - -
-
, +
+ + +
, document.getElementById('root') ); diff --git a/modules/client/main/About.js b/modules/client/main/About.js deleted file mode 100644 index d93aff2..0000000 --- a/modules/client/main/About.js +++ /dev/null @@ -1,95 +0,0 @@ -import React from 'react'; - -import Wrapper from './Wrapper'; - -import cloudflareLogo from './CloudflareLogo.png'; -import herokuLogo from './HerokuLogo.png'; - -const styles = { - logoList: { - margin: '2em 0', - display: 'flex', - justifyContent: 'center' - }, - logo: { - textAlign: 'center', - flex: '1', - maxWidth: '80%' - }, - logoImage: { - maxWidth: '60%' - } -}; - -function AboutLogo({ children }) { - return
{children}
; -} - -function AboutLogoImage(props) { - return ; -} - -export default function About() { - return ( - -

- unpkg is an open source project - built and maintained by{' '} - Michael Jackson. -

- -

Sponsors

-

- The fast, global infrastructure that powers unpkg is generously donated - by Cloudflare and{' '} - Heroku. -

- -
- - - - - - - - - - -
- -

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. -

- -

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
{children}
; +} - adjustUnderline = (useSpring = false) => { - let itemIndex; - switch (this.props.location.pathname) { - case '/stats': - itemIndex = 1; - break; - case '/about': - itemIndex = 2; - break; - case '/': - default: - itemIndex = 0; - } +function AboutLogoImage(props) { + return ; +} - const itemNodes = this.listNode.querySelectorAll('li'); - const currentNode = itemNodes[itemIndex]; +function Stats({ data }) { + const totals = data.totals; + const since = parseDate(totals.since); + const until = parseDate(totals.until); - this.setState({ - underlineLeft: currentNode.offsetLeft, - underlineWidth: currentNode.offsetWidth, - useSpring - }); - }; + 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. +

+ ); +} + +export default class App extends React.Component { + state = { stats: null }; componentDidMount() { - this.adjustUnderline(); - fetch('/api/stats?period=last-month') .then(res => res.json()) .then(stats => this.setState({ stats })); @@ -93,83 +111,217 @@ class Layout extends React.Component { } } - componentDidUpdate(prevProps) { - if (prevProps.location.pathname !== this.props.location.pathname) { - this.adjustUnderline(true); - } - } - render() { - const { underlineLeft, underlineWidth, useSpring } = this.state; - - const style = { - left: useSpring - ? spring(underlineLeft, { stiffness: 220 }) - : underlineLeft, - width: useSpring ? spring(underlineWidth) : underlineWidth - }; + const { stats } = this.state; return ( -
- +
+
+

unpkg

-
-
-

unpkg

- -
+

+ 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: +

+ +
unpkg.com/:package@:version/:file
+ + {stats && } +
+ +

Examples

+ +

Using a fixed version:

+ + + +

+ 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. +

+ + + +

+ Append a / at the end of a URL to view a listing of all + the files in a package. +

+ + + +

Query Parameters

+ +
+
+ ?meta +
+
+ 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. +

+ +
+ + + + + + + + + +
- - } - /> - - - +

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. +

); } } if (process.env.NODE_ENV !== 'production') { - Layout.propTypes = { + App.propTypes = { location: PropTypes.object, children: PropTypes.node }; } - -export default withRouter(Layout); diff --git a/modules/client/main/Home.js b/modules/client/main/Home.js deleted file mode 100644 index 1917cdf..0000000 --- a/modules/client/main/Home.js +++ /dev/null @@ -1,159 +0,0 @@ -import React from 'react'; - -import Wrapper from './Wrapper'; - -const styles = { - homeExample: { - textAlign: 'center', - backgroundColor: '#eee', - margin: '2em 0', - padding: '5px 0' - } -}; - -export default function Home() { - return ( - -

- 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: -

- -
unpkg.com/:package@:version/:file
- -

Examples

- -

Using a fixed version:

- - - -

- 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. -

- - - -

- Append a / at the end of a URL to view a listing of all the - files in a package. -

- - - -

Query Parameters

- -
-
- ?meta -
-
- 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. -

-
- ); -} diff --git a/modules/client/main/Stats.js b/modules/client/main/Stats.js deleted file mode 100644 index fbfc6f1..0000000 --- a/modules/client/main/Stats.js +++ /dev/null @@ -1,337 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import formatBytes from 'pretty-bytes'; -import formatDate from 'date-fns/format'; -import parseDate from 'date-fns/parse'; - -import { continents, countries } from './countries.json'; - -import Wrapper from './Wrapper'; -import formatNumber from '../utils/formatNumber'; -import formatPercent from '../utils/formatPercent'; - -const styles = { - tableFilter: { - fontSize: '0.8em', - textAlign: 'right' - }, - countryName: { - paddingLeft: 20 - } -}; - -function getCountriesByContinent(continent) { - return Object.keys(countries).filter( - country => countries[country].continent === continent - ); -} - -function sumKeyValues(hash, keys) { - return keys.reduce((n, key) => n + (hash[key] || 0), 0); -} - -// function sumValues(hash) { -// return Object.keys(hash).reduce((memo, key) => memo + hash[key], 0); -// } - -export default class Stats extends React.Component { - state = { - // minPackageRequests: 1000000, - minCountryRequests: 1000000 - }; - - render() { - const { data } = this.props; - - if (data == null) return null; - - const totals = data.totals; - - // Summary data - const since = parseDate(totals.since); - const until = parseDate(totals.until); - - // Packages - // const packageRows = []; - - // Object.keys(totals.requests.package) - // .sort((a, b) => { - // return totals.requests.package[b] - totals.requests.package[a]; - // }) - // .forEach(packageName => { - // const requests = totals.requests.package[packageName]; - // const bandwidth = totals.bandwidth.package[packageName]; - - // if (requests >= this.state.minPackageRequests) { - // packageRows.push( - // - // - // - // {packageName} - // - // - // - // {formatNumber(requests)} ( - // {formatPercent(requests / totals.requests.all)} - // %) - // - // {bandwidth ? ( - // - // {formatBytes(bandwidth)} ( - // {formatPercent(bandwidth / totals.bandwidth.all)} - // %) - // - // ) : ( - // - - // )} - // - // ); - // } - // }); - - // Regions - const regionRows = []; - - const continentsData = Object.keys(continents).reduce((memo, continent) => { - const localCountries = getCountriesByContinent(continent); - - memo[continent] = { - countries: localCountries, - requests: sumKeyValues(totals.requests.country, localCountries), - bandwidth: sumKeyValues(totals.bandwidth.country, localCountries) - }; - - return memo; - }, {}); - - const topContinents = Object.keys(continentsData).sort((a, b) => { - return continentsData[b].requests - continentsData[a].requests; - }); - - topContinents.forEach(continent => { - const continentName = continents[continent]; - const continentData = continentsData[continent]; - - if ( - continentData.requests > this.state.minCountryRequests && - continentData.bandwidth !== 0 - ) { - regionRows.push( - - - {continentName} - - - - {formatNumber(continentData.requests)} ( - {formatPercent(continentData.requests / totals.requests.all)} - %) - - - - - {formatBytes(continentData.bandwidth)} ( - {formatPercent(continentData.bandwidth / totals.bandwidth.all)} - %) - - - - ); - - const topCountries = continentData.countries.sort((a, b) => { - return totals.requests.country[b] - totals.requests.country[a]; - }); - - topCountries.forEach(country => { - const countryRequests = totals.requests.country[country]; - const countryBandwidth = totals.bandwidth.country[country]; - - if (countryRequests > this.state.minCountryRequests) { - regionRows.push( - - {countries[country].name} - - {formatNumber(countryRequests)} ( - {formatPercent(countryRequests / totals.requests.all)} - %) - - - {formatBytes(countryBandwidth)} ( - {formatPercent(countryBandwidth / totals.bandwidth.all)} - %) - - - ); - } - }); - } - }); - - // Protocols - // const protocolRows = Object.keys(totals.requests.protocol) - // .sort((a, b) => { - // return totals.requests.protocol[b] - totals.requests.protocol[a]; - // }) - // .map(protocol => { - // const requests = totals.requests.protocol[protocol]; - - // return ( - // - // {protocol} - // - // {formatNumber(requests)} ( - // {formatPercent(requests / sumValues(totals.requests.protocol))} - // %) - // - // - // ); - // }); - - 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. -

- -

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. -

- - - - - - - - - - {packageRows} -
- Package - - Requests (% of total) - - Bandwidth (% of total) -
- */} - -

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. -

- - - - - - - - - - {regionRows} -
- Region - - Requests (% of total) - - Bandwidth (% of total) -
- - {/* -

Protocols

- -

- The table below breaks down requests to unpkg from{' '} - {formatDate(since, 'MMM D')} to{' '} - {formatDate(until, 'MMM D')} by HTTP protocol. -

- - - - - - - - - {protocolRows} -
- Protocol - - Requests (% of total) -
- */} -
- ); - } -} - -if (process.env.NODE_ENV !== 'production') { - Stats.propTypes = { - data: PropTypes.object - }; -} diff --git a/modules/client/main/WindowSize.js b/modules/client/main/WindowSize.js deleted file mode 100644 index 1d74954..0000000 --- a/modules/client/main/WindowSize.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { addEvent, removeEvent } from '../utils/dom'; - -const resizeEvent = 'resize'; - -export default class WindowSize extends React.Component { - handleWindowResize = () => { - if (this.props.onChange) { - this.props.onChange({ - width: window.innerWidth, - height: window.innerHeight - }); - } - }; - - componentDidMount() { - addEvent(window, resizeEvent, this.handleWindowResize); - } - - componentWillUnmount() { - removeEvent(window, resizeEvent, this.handleWindowResize); - } - - render() { - return null; - } -} - -if (process.env.NODE_ENV !== 'production') { - WindowSize.propTypes = { - onChange: PropTypes.func - }; -} diff --git a/modules/client/main/Wrapper.js b/modules/client/main/Wrapper.js deleted file mode 100644 index ed96a05..0000000 --- a/modules/client/main/Wrapper.js +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react'; - -export default function Wrapper({ children }) { - return
{children}
; -} diff --git a/modules/client/main/countries.json b/modules/client/main/countries.json deleted file mode 100644 index 1654211..0000000 --- a/modules/client/main/countries.json +++ /dev/null @@ -1 +0,0 @@ -{"continents":{"AF":"Africa","AN":"Antarctica","AS":"Asia","EU":"Europe","NA":"North America","OC":"Oceania","SA":"South America"},"countries":{"AD":{"name":"Andorra","continent":"EU"},"AE":{"name":"United Arab Emirates","continent":"AS"},"AF":{"name":"Afghanistan","continent":"AS"},"AG":{"name":"Antigua and Barbuda","continent":"NA"},"AI":{"name":"Anguilla","continent":"NA"},"AL":{"name":"Albania","continent":"EU"},"AM":{"name":"Armenia","continent":"AS"},"AO":{"name":"Angola","continent":"AF"},"AQ":{"name":"Antarctica","continent":"AN"},"AR":{"name":"Argentina","continent":"SA"},"AS":{"name":"American Samoa","continent":"OC"},"AT":{"name":"Austria","continent":"EU"},"AU":{"name":"Australia","continent":"OC"},"AW":{"name":"Aruba","continent":"NA"},"AX":{"name":"Åland","continent":"EU"},"AZ":{"name":"Azerbaijan","continent":"AS"},"BA":{"name":"Bosnia and Herzegovina","continent":"EU"},"BB":{"name":"Barbados","continent":"NA"},"BD":{"name":"Bangladesh","continent":"AS"},"BE":{"name":"Belgium","continent":"EU"},"BF":{"name":"Burkina Faso","continent":"AF"},"BG":{"name":"Bulgaria","continent":"EU"},"BH":{"name":"Bahrain","continent":"AS"},"BI":{"name":"Burundi","continent":"AF"},"BJ":{"name":"Benin","continent":"AF"},"BL":{"name":"Saint Barthélemy","continent":"NA"},"BM":{"name":"Bermuda","continent":"NA"},"BN":{"name":"Brunei","continent":"AS"},"BO":{"name":"Bolivia","continent":"SA"},"BQ":{"name":"Bonaire","continent":"NA"},"BR":{"name":"Brazil","continent":"SA"},"BS":{"name":"Bahamas","continent":"NA"},"BT":{"name":"Bhutan","continent":"AS"},"BV":{"name":"Bouvet Island","continent":"AN"},"BW":{"name":"Botswana","continent":"AF"},"BY":{"name":"Belarus","continent":"EU"},"BZ":{"name":"Belize","continent":"NA"},"CA":{"name":"Canada","continent":"NA"},"CC":{"name":"Cocos [Keeling] Islands","continent":"AS"},"CD":{"name":"Democratic Republic of the Congo","continent":"AF"},"CF":{"name":"Central African Republic","continent":"AF"},"CG":{"name":"Republic of the Congo","continent":"AF"},"CH":{"name":"Switzerland","continent":"EU"},"CI":{"name":"Ivory Coast","continent":"AF"},"CK":{"name":"Cook Islands","continent":"OC"},"CL":{"name":"Chile","continent":"SA"},"CM":{"name":"Cameroon","continent":"AF"},"CN":{"name":"China","continent":"AS"},"CO":{"name":"Colombia","continent":"SA"},"CR":{"name":"Costa Rica","continent":"NA"},"CU":{"name":"Cuba","continent":"NA"},"CV":{"name":"Cape Verde","continent":"AF"},"CW":{"name":"Curacao","continent":"NA"},"CX":{"name":"Christmas Island","continent":"AS"},"CY":{"name":"Cyprus","continent":"EU"},"CZ":{"name":"Czech Republic","continent":"EU"},"DE":{"name":"Germany","continent":"EU"},"DJ":{"name":"Djibouti","continent":"AF"},"DK":{"name":"Denmark","continent":"EU"},"DM":{"name":"Dominica","continent":"NA"},"DO":{"name":"Dominican Republic","continent":"NA"},"DZ":{"name":"Algeria","continent":"AF"},"EC":{"name":"Ecuador","continent":"SA"},"EE":{"name":"Estonia","continent":"EU"},"EG":{"name":"Egypt","continent":"AF"},"EH":{"name":"Western Sahara","continent":"AF"},"ER":{"name":"Eritrea","continent":"AF"},"ES":{"name":"Spain","continent":"EU"},"ET":{"name":"Ethiopia","continent":"AF"},"FI":{"name":"Finland","continent":"EU"},"FJ":{"name":"Fiji","continent":"OC"},"FK":{"name":"Falkland Islands","continent":"SA"},"FM":{"name":"Micronesia","continent":"OC"},"FO":{"name":"Faroe Islands","continent":"EU"},"FR":{"name":"France","continent":"EU"},"GA":{"name":"Gabon","continent":"AF"},"GB":{"name":"United Kingdom","continent":"EU"},"GD":{"name":"Grenada","continent":"NA"},"GE":{"name":"Georgia","continent":"AS"},"GF":{"name":"French Guiana","continent":"SA"},"GG":{"name":"Guernsey","continent":"EU"},"GH":{"name":"Ghana","continent":"AF"},"GI":{"name":"Gibraltar","continent":"EU"},"GL":{"name":"Greenland","continent":"NA"},"GM":{"name":"Gambia","continent":"AF"},"GN":{"name":"Guinea","continent":"AF"},"GP":{"name":"Guadeloupe","continent":"NA"},"GQ":{"name":"Equatorial Guinea","continent":"AF"},"GR":{"name":"Greece","continent":"EU"},"GS":{"name":"South Georgia and the South Sandwich Islands","continent":"AN"},"GT":{"name":"Guatemala","continent":"NA"},"GU":{"name":"Guam","continent":"OC"},"GW":{"name":"Guinea-Bissau","continent":"AF"},"GY":{"name":"Guyana","continent":"SA"},"HK":{"name":"Hong Kong","continent":"AS"},"HM":{"name":"Heard Island and McDonald Islands","continent":"AN"},"HN":{"name":"Honduras","continent":"NA"},"HR":{"name":"Croatia","continent":"EU"},"HT":{"name":"Haiti","continent":"NA"},"HU":{"name":"Hungary","continent":"EU"},"ID":{"name":"Indonesia","continent":"AS"},"IE":{"name":"Ireland","continent":"EU"},"IL":{"name":"Israel","continent":"AS"},"IM":{"name":"Isle of Man","continent":"EU"},"IN":{"name":"India","continent":"AS"},"IO":{"name":"British Indian Ocean Territory","continent":"AS"},"IQ":{"name":"Iraq","continent":"AS"},"IR":{"name":"Iran","continent":"AS"},"IS":{"name":"Iceland","continent":"EU"},"IT":{"name":"Italy","continent":"EU"},"JE":{"name":"Jersey","continent":"EU"},"JM":{"name":"Jamaica","continent":"NA"},"JO":{"name":"Jordan","continent":"AS"},"JP":{"name":"Japan","continent":"AS"},"KE":{"name":"Kenya","continent":"AF"},"KG":{"name":"Kyrgyzstan","continent":"AS"},"KH":{"name":"Cambodia","continent":"AS"},"KI":{"name":"Kiribati","continent":"OC"},"KM":{"name":"Comoros","continent":"AF"},"KN":{"name":"Saint Kitts and Nevis","continent":"NA"},"KP":{"name":"North Korea","continent":"AS"},"KR":{"name":"South Korea","continent":"AS"},"KW":{"name":"Kuwait","continent":"AS"},"KY":{"name":"Cayman Islands","continent":"NA"},"KZ":{"name":"Kazakhstan","continent":"AS"},"LA":{"name":"Laos","continent":"AS"},"LB":{"name":"Lebanon","continent":"AS"},"LC":{"name":"Saint Lucia","continent":"NA"},"LI":{"name":"Liechtenstein","continent":"EU"},"LK":{"name":"Sri Lanka","continent":"AS"},"LR":{"name":"Liberia","continent":"AF"},"LS":{"name":"Lesotho","continent":"AF"},"LT":{"name":"Lithuania","continent":"EU"},"LU":{"name":"Luxembourg","continent":"EU"},"LV":{"name":"Latvia","continent":"EU"},"LY":{"name":"Libya","continent":"AF"},"MA":{"name":"Morocco","continent":"AF"},"MC":{"name":"Monaco","continent":"EU"},"MD":{"name":"Moldova","continent":"EU"},"ME":{"name":"Montenegro","continent":"EU"},"MF":{"name":"Saint Martin","continent":"NA"},"MG":{"name":"Madagascar","continent":"AF"},"MH":{"name":"Marshall Islands","continent":"OC"},"MK":{"name":"Macedonia","continent":"EU"},"ML":{"name":"Mali","continent":"AF"},"MM":{"name":"Myanmar [Burma]","continent":"AS"},"MN":{"name":"Mongolia","continent":"AS"},"MO":{"name":"Macao","continent":"AS"},"MP":{"name":"Northern Mariana Islands","continent":"OC"},"MQ":{"name":"Martinique","continent":"NA"},"MR":{"name":"Mauritania","continent":"AF"},"MS":{"name":"Montserrat","continent":"NA"},"MT":{"name":"Malta","continent":"EU"},"MU":{"name":"Mauritius","continent":"AF"},"MV":{"name":"Maldives","continent":"AS"},"MW":{"name":"Malawi","continent":"AF"},"MX":{"name":"Mexico","continent":"NA"},"MY":{"name":"Malaysia","continent":"AS"},"MZ":{"name":"Mozambique","continent":"AF"},"NA":{"name":"Namibia","continent":"AF"},"NC":{"name":"New Caledonia","continent":"OC"},"NE":{"name":"Niger","continent":"AF"},"NF":{"name":"Norfolk Island","continent":"OC"},"NG":{"name":"Nigeria","continent":"AF"},"NI":{"name":"Nicaragua","continent":"NA"},"NL":{"name":"Netherlands","continent":"EU"},"NO":{"name":"Norway","continent":"EU"},"NP":{"name":"Nepal","continent":"AS"},"NR":{"name":"Nauru","continent":"OC"},"NU":{"name":"Niue","continent":"OC"},"NZ":{"name":"New Zealand","continent":"OC"},"OM":{"name":"Oman","continent":"AS"},"PA":{"name":"Panama","continent":"NA"},"PE":{"name":"Peru","continent":"SA"},"PF":{"name":"French Polynesia","continent":"OC"},"PG":{"name":"Papua New Guinea","continent":"OC"},"PH":{"name":"Philippines","continent":"AS"},"PK":{"name":"Pakistan","continent":"AS"},"PL":{"name":"Poland","continent":"EU"},"PM":{"name":"Saint Pierre and Miquelon","continent":"NA"},"PN":{"name":"Pitcairn Islands","continent":"OC"},"PR":{"name":"Puerto Rico","continent":"NA"},"PS":{"name":"Palestine","continent":"AS"},"PT":{"name":"Portugal","continent":"EU"},"PW":{"name":"Palau","continent":"OC"},"PY":{"name":"Paraguay","continent":"SA"},"QA":{"name":"Qatar","continent":"AS"},"RE":{"name":"Réunion","continent":"AF"},"RO":{"name":"Romania","continent":"EU"},"RS":{"name":"Serbia","continent":"EU"},"RU":{"name":"Russia","continent":"EU"},"RW":{"name":"Rwanda","continent":"AF"},"SA":{"name":"Saudi Arabia","continent":"AS"},"SB":{"name":"Solomon Islands","continent":"OC"},"SC":{"name":"Seychelles","continent":"AF"},"SD":{"name":"Sudan","continent":"AF"},"SE":{"name":"Sweden","continent":"EU"},"SG":{"name":"Singapore","continent":"AS"},"SH":{"name":"Saint Helena","continent":"AF"},"SI":{"name":"Slovenia","continent":"EU"},"SJ":{"name":"Svalbard and Jan Mayen","continent":"EU"},"SK":{"name":"Slovakia","continent":"EU"},"SL":{"name":"Sierra Leone","continent":"AF"},"SM":{"name":"San Marino","continent":"EU"},"SN":{"name":"Senegal","continent":"AF"},"SO":{"name":"Somalia","continent":"AF"},"SR":{"name":"Suriname","continent":"SA"},"SS":{"name":"South Sudan","continent":"AF"},"ST":{"name":"São Tomé and Príncipe","continent":"AF"},"SV":{"name":"El Salvador","continent":"NA"},"SX":{"name":"Sint Maarten","continent":"NA"},"SY":{"name":"Syria","continent":"AS"},"SZ":{"name":"Swaziland","continent":"AF"},"TC":{"name":"Turks and Caicos Islands","continent":"NA"},"TD":{"name":"Chad","continent":"AF"},"TF":{"name":"French Southern Territories","continent":"AN"},"TG":{"name":"Togo","continent":"AF"},"TH":{"name":"Thailand","continent":"AS"},"TJ":{"name":"Tajikistan","continent":"AS"},"TK":{"name":"Tokelau","continent":"OC"},"TL":{"name":"East Timor","continent":"OC"},"TM":{"name":"Turkmenistan","continent":"AS"},"TN":{"name":"Tunisia","continent":"AF"},"TO":{"name":"Tonga","continent":"OC"},"TR":{"name":"Turkey","continent":"AS"},"TT":{"name":"Trinidad and Tobago","continent":"NA"},"TV":{"name":"Tuvalu","continent":"OC"},"TW":{"name":"Taiwan","continent":"AS"},"TZ":{"name":"Tanzania","continent":"AF"},"UA":{"name":"Ukraine","continent":"EU"},"UG":{"name":"Uganda","continent":"AF"},"UM":{"name":"U.S. Minor Outlying Islands","continent":"OC"},"US":{"name":"United States","continent":"NA"},"UY":{"name":"Uruguay","continent":"SA"},"UZ":{"name":"Uzbekistan","continent":"AS"},"VA":{"name":"Vatican City","continent":"EU"},"VC":{"name":"Saint Vincent and the Grenadines","continent":"NA"},"VE":{"name":"Venezuela","continent":"SA"},"VG":{"name":"British Virgin Islands","continent":"NA"},"VI":{"name":"U.S. Virgin Islands","continent":"NA"},"VN":{"name":"Vietnam","continent":"AS"},"VU":{"name":"Vanuatu","continent":"OC"},"WF":{"name":"Wallis and Futuna","continent":"OC"},"WS":{"name":"Samoa","continent":"OC"},"XK":{"name":"Kosovo","continent":"EU"},"YE":{"name":"Yemen","continent":"AS"},"YT":{"name":"Mayotte","continent":"AF"},"ZA":{"name":"South Africa","continent":"AF"},"ZM":{"name":"Zambia","continent":"AF"},"ZW":{"name":"Zimbabwe","continent":"AF"}}} diff --git a/modules/client/utils/dom.js b/modules/client/utils/dom.js deleted file mode 100644 index e36fc3c..0000000 --- a/modules/client/utils/dom.js +++ /dev/null @@ -1,15 +0,0 @@ -export function addEvent(node, type, handler) { - if (node.addEventListener) { - node.addEventListener(type, handler, false); - } else if (node.attachEvent) { - node.attachEvent('on' + type, handler); - } -} - -export function removeEvent(node, type, handler) { - if (node.removeEventListener) { - node.removeEventListener(type, handler, false); - } else if (node.detachEvent) { - node.detachEvent('on' + type, handler); - } -} diff --git a/modules/client/utils/parseNumber.js b/modules/client/utils/parseNumber.js deleted file mode 100644 index cd8cd85..0000000 --- a/modules/client/utils/parseNumber.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function parseNumber(s) { - return parseInt(s.replace(/,/g, ''), 10) || 0; -} diff --git a/package-lock.json b/package-lock.json index 8089c77..00a8166 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2437,12 +2437,6 @@ } } }, - "countries-list": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/countries-list/-/countries-list-1.4.1.tgz", - "integrity": "sha1-R+JU/WD1NmDUstGUrhF/qTjqfCk=", - "dev": true - }, "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", @@ -4232,33 +4226,6 @@ } } }, - "history": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/history/-/history-4.7.2.tgz", - "integrity": "sha512-1zkBRWW6XweO0NBcjiphtVJVsIQ+SXF29z9DVkceeaSLVMFXHool+fdCZD4spDCfZJCILPILc3bm7Bc+HRi0nA==", - "requires": { - "invariant": "^2.2.1", - "loose-envify": "^1.2.0", - "resolve-pathname": "^2.2.0", - "value-equal": "^0.4.0", - "warning": "^3.0.0" - }, - "dependencies": { - "warning": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", - "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", - "requires": { - "loose-envify": "^1.0.0" - } - } - } - }, - "hoist-non-react-statics": { - "version": "2.5.5", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", - "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" - }, "hosted-git-info": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", @@ -4399,6 +4366,7 @@ "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, "requires": { "loose-envify": "^1.0.0" } @@ -6117,21 +6085,6 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "requires": { - "isarray": "0.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - } - } - }, "path-type": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", @@ -6356,33 +6309,6 @@ "raf": "^3.1.0" } }, - "react-router": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz", - "integrity": "sha512-yrvL8AogDh2X42Dt9iknk4wF4V8bWREPirFfS9gLU1huk6qK41sg7Z/1S81jjTrGHxa3B8R3J6xIkDAA6CVarg==", - "requires": { - "history": "^4.7.2", - "hoist-non-react-statics": "^2.5.0", - "invariant": "^2.2.4", - "loose-envify": "^1.3.1", - "path-to-regexp": "^1.7.0", - "prop-types": "^15.6.1", - "warning": "^4.0.1" - } - }, - "react-router-dom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-4.3.1.tgz", - "integrity": "sha512-c/MlywfxDdCp7EnB7YfPMOfMD3tOtIjrQlj/CKfNMBxdmpJP8xcz5P/UAFn3JbnQCNUxsHyVVqllF9LhgVyFCA==", - "requires": { - "history": "^4.7.2", - "invariant": "^2.2.4", - "loose-envify": "^1.3.1", - "prop-types": "^15.6.1", - "react-router": "^4.3.1", - "warning": "^4.0.1" - } - }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", @@ -6678,11 +6604,6 @@ "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, - "resolve-pathname": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.2.0.tgz", - "integrity": "sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==" - }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -8079,11 +8000,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "value-equal": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-0.4.0.tgz", - "integrity": "sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw==" - }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -8113,14 +8029,6 @@ "makeerror": "1.0.x" } }, - "warning": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.2.tgz", - "integrity": "sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==", - "requires": { - "loose-envify": "^1.0.0" - } - }, "watch": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/watch/-/watch-0.18.0.tgz", diff --git a/package.json b/package.json index ba3808f..181b7b0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "react": "^16.7.0", "react-dom": "^16.7.0", "react-motion": "^0.5.2", - "react-router-dom": "^4.3.1", "sort-by": "^1.2.0" }, "devDependencies": { @@ -29,7 +28,6 @@ "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^8.0.3", "babel-jest": "^23.4.2", - "countries-list": "^1.4.1", "dotenv": "^6.2.0", "eslint": "^4.13.1", "eslint-import-resolver-node": "^0.3.2", diff --git a/scripts/generate-countries-json.js b/scripts/generate-countries-json.js deleted file mode 100644 index 18e0359..0000000 --- a/scripts/generate-countries-json.js +++ /dev/null @@ -1,12 +0,0 @@ -const countriesList = require('countries-list'); - -const json = JSON.stringify({ - continents: countriesList.continents, - countries: Object.keys(countriesList.countries).reduce((memo, key) => { - const { name, continent } = countriesList.countries[key]; - memo[key] = { name, continent }; - return memo; - }, {}) -}); - -console.log(json);