express-npmcdn
v0.0.1
Published
Hosting npm package files
Downloads
181
Readme
Express NpmCDN
Hosting npm package files
Usage
npm install express --save
npm install cors --save
npm install compression --save
npm install express-npmcdn --save
import express from 'express';
import cors from 'cors';
import compression from 'compression';
import npmcdn from 'express-npmcdn';
const port = process.env.PORT || 59798;
const app = express();
app.disable('x-powered-by');
app.use(cors());
app.use(compression());
app.use(npmcdn(`${__dirname}/public/packages/`, {
api: 'http://registry.npmjs.org', // tarbal source
maxAge: 60 * 60 * 24 * 365, // one year
extensions: ['', '.js', '.json', '.html'], // resolve extensions
}));
app.listen(port, () => {
console.log(`npmcdn is available on http://localhost:${port}!`);
});
becomes:
curl -I http://localhost:59798/jquery
# HTTP/1.1 302 Found
# Access-Control-Allow-Origin: *
# Location: /[email protected]/
curl -I http://localhost:59798/[email protected]/
# HTTP/1.1 200 OK
# Access-Control-Allow-Origin: *
# Content-Type: application/javascript
# Content-Length: 258549
#...
Test
git clone https://github.com/59naga/express-npmcdn.git
cd express-npmcdn
npm install
npm test