vapr-conditionals
Version:
A Vapr plugin for handling conditional requests
25 lines (21 loc) • 694 B
JavaScript
;
const http = require('http');
const app = require('vapr')();
const timestamp = Date.UTC(2020, 4, 15);
app.get('/', require('.')(), (req) => {
req.validate({ strong: ['foo', 'bar'] });
return [['hello world']];
});
const server = http.createServer(app).listen(3000, () => {
http.get({ path: '/', port: 3000, headers: {
'if-match': '"AQX8vJ7qgZPejhg0Z3tsaw=="',
// 'if-unmodified-since': new Date(timestamp + 1000).toGMTString(),
// 'if-none-match': 'W/"AQX8vJ7qgZPejhg0Z3tsaw=="',
// 'if-modified-since': new Date(timestamp - 1000).toGMTString(),
} }, (res) => {
console.log(res.statusCode);
console.log(res.headers);
res.destroy();
server.close();
});
});