diff --git a/examples/with-sirv/index.js b/examples/with-sirv/index.js new file mode 100644 index 0000000..152d3eb --- /dev/null +++ b/examples/with-sirv/index.js @@ -0,0 +1,13 @@ +const polka = require('polka'); + +const { PORT=3000 } = process.env; +const serve = require('sirv')('public'); + +polka() + .use(serve) + .get('/health', (req, res) => { + res.end('OK'); + }) + .listen(PORT).then(_ => { + console.log(`> Running on localhost:${PORT}`); + }); diff --git a/examples/with-sirv/package.json b/examples/with-sirv/package.json new file mode 100644 index 0000000..5982d3e --- /dev/null +++ b/examples/with-sirv/package.json @@ -0,0 +1,9 @@ +{ + "scripts": { + "start": "node index" + }, + "dependencies": { + "polka": "latest", + "sirv": "latest" + } +} diff --git a/examples/with-sirv/public/app.js b/examples/with-sirv/public/app.js new file mode 100644 index 0000000..bba289e --- /dev/null +++ b/examples/with-sirv/public/app.js @@ -0,0 +1,20 @@ +(function () { + let i=0, img, arr=[]; + let doc=document, app=doc.getElementById('app'), images=[ + 'uOi3lg8fGl4', 'OjVIrvBKWP8', 'uSFOwYo1qEw', 'tZaA8VqJG3g', + '9yWcy5B-haM', '_MeRaXKnEYo', 'HrkyU8bVwYI', 'Yohivf5JWvg', + '78A265wPiO4', 'TAhsXhWipwg', 'dQBZY7yEVpc', '6k2FqycNmwU' + ]; + + for (; i < images.length; i++) { + img = doc.createElement('img'); + img.src = 'https://source.unsplash.com/' + images[i]; + arr.push(img) && app.appendChild(img); + } + + onloaded(arr, { + onComplete() { + app.className = 'rdy'; + } + }); +})(); diff --git a/examples/with-sirv/public/index.html b/examples/with-sirv/public/index.html new file mode 100644 index 0000000..de306e7 --- /dev/null +++ b/examples/with-sirv/public/index.html @@ -0,0 +1,13 @@ + + +
+ +