general code improvements part 1

This commit is contained in:
David Ralph
2019-02-18 09:38:56 +00:00
committed by GitHub
parent 0cc238b831
commit 2a23647ce8

View File

@@ -1,16 +1,16 @@
const { parse } = require( 'url' );
const { parse } = require('url');
module.exports = class KirbeRequest {
constructor( req, body ) {
constructor(req, body) {
this.url = req.url;
this.req = req;
this.req = req;
this.body = body;
this.from = req.connection.remoteAddress;
this.method = req.method;
this.headers = req.headers;
this.parsedUrl = parse( this.url, true );
this.parsedUrl = parse(this.url, true);
}
json() { return JSON.parse( this.body ); }
query ( name ) { return this.parsedUrl.query[ name ]; }
};
json() { return JSON.parse(this.body); }
query (name) { return this.parsedUrl.query[name]; }
};