UNPKG

vapr-static

Version:

A Vapr plugin that provides a basic static file server

29 lines (26 loc) 681 B
'use strict'; const http = require('http'); const app = require('vapr')(); const plugin = require('.'); app.get('/hello', () => [['hello world!']]); app.notFound() .use((req) => (res) => { console.log(plugin.getFilename(req)); res.error && console.log(res.error); }) .use(plugin({ root: '.', broker: (pathname) => { return pathname + '.js'; }, })); const server = http.createServer(app).listen(3000, () => { http.request({ method: 'GET', path: '/lib/index', port: 3000, headers: { // 'if-none-match': 'W/"wLj8QkkGFIrd0dZxXxt1Rw=="', } }, (res) => { console.log(res.statusCode); console.log(res.headers); res.destroy(); server.close(); }).end(); });