commit eeb7b62dcef131bfbeda8b75026c9220fe5b3812 Author: Michael Jackson Date: Sun Feb 21 18:52:19 2016 -0800 Initial commit diff --git a/package.json b/package.json new file mode 100644 index 0000000..ded1e57 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "npmcdn.com", + "version": "1.0.0", + "author": "Michael Jackson", + "license": "MIT", + "main": "server.js", + "dependencies": { + "cors": "^2.7.1", + "express": "^4.13.4" + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..4b28f59 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..a0baeb8 --- /dev/null +++ b/public/index.html @@ -0,0 +1,110 @@ + + + + npmcdn + + + + +
+

npmcdn

+
+
+

npmcdn is a CDN for packages that are published via npm. Use it to quickly and easily load files using a simple URL like https://npmcdn.com/package@version/path/to/file.

+

A few examples:

+ + +

You may also use a tag or version range instead of a fixed version number, or omit the version/tag entirely to use the latest tag.

+ + +

If you omit the file path, the main module will be returned. This is especially useful for loading libaries that publish a UMD build as their main module.

+ + +

If you use the special /bower.zip file path in a package that contains a bower.json file, a zip file will be created on the fly that Bower can use to install the package.

+ + +

Please note: We do NOT recommend JavaScript libraries use Bower. Bower places additional burdens on JavaScript package authors for little to no gain. npmcdn is intended to make it easier to publish code, not harder, so Bower support will be removed in January 2017. Please move to npm for installing packages and stop using Bower before that time. See here for our rationale.

+ +

Query Parameters

+ + + + + + + + + + + + + + + +
NameDefault ValueDescription
mainmainThe name of the field in package.json to use as the main entry point when there is no file path in the URL. This value may be dot-separated to specify a nested field (e.g. ?main=config.browserMain).
+ +

Suggested Workflow

+

For npm package authors, npmcdn 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:

+ + +

Feedback

+

If you think this is useful, I'd love to hear from you. Please reach out to @mjackson with any questions/concerns.

+

Also, please feel free to examine the source on GitHub.

+
+ + diff --git a/server.js b/server.js new file mode 100644 index 0000000..1037725 --- /dev/null +++ b/server.js @@ -0,0 +1,18 @@ +var port = process.env.PORT || 5000 + +var express = require('express') +var createRequestHandler = require('npm-http-server').createRequestHandler +var cors = require('cors') + +var app = express() + +app.disable('x-powered-by') +app.use(cors()) +app.use(express.static('public', { maxAge: 60000 })) +app.use( + createRequestHandler() +) + +app.listen(port, function () { + console.log('Server started on port ' + port + '. Ctrl+C to quit') +})