Comparing version 0.1.0-beta-62 to 0.1.0-beta-63
@@ -184,4 +184,3 @@ "use strict"; | ||
request: request, | ||
response: response, | ||
encoding: server.getEncoding() | ||
response: response | ||
}, request.url); | ||
@@ -188,0 +187,0 @@ /// parse request |
@@ -21,3 +21,3 @@ "use strict"; | ||
this.type = type; | ||
this.body = body; | ||
this.body = body.toString('binary'); | ||
this.parsedBody = {}; | ||
@@ -86,11 +86,10 @@ }, | ||
var data = {}, splits; | ||
splits = body.split("--" + boundary); | ||
splits.shift(); | ||
splits.pop(); | ||
if (splits.length > 0) { | ||
splits = splits.map(function (item) { | ||
return item.replace(/^\r\n/, '').replace(/\r\n$/, '').trim(); | ||
splits = splits.slice(1, splits.length - 1).map(function (item) { | ||
return item.slice(2, item.length - 2); | ||
}); | ||
splits.forEach(function (item) { | ||
@@ -105,5 +104,11 @@ var fileName = this.parseFileName(item), | ||
obj.name = name; | ||
if (!!fileName) { | ||
obj.fileName = fileName; | ||
obj.value = new Buffer(value, 'binary'); | ||
} else { | ||
obj.value = value; | ||
} | ||
if (!!contentType) { | ||
@@ -115,4 +120,4 @@ obj.contentType = contentType; | ||
} | ||
obj.name = name; | ||
obj.value = value; | ||
if (data.hasOwnProperty(name)) { | ||
@@ -209,5 +214,3 @@ temp = data[name]; | ||
parseValue: function BodyParser_parseValue(str) { | ||
var value = str.split(/\r\n\r\n/); | ||
value.shift(); | ||
return value.join('\\r\\n\\r\\n'); | ||
return str.replace(/(.*)(([\S\s]+)(Content-Type:(.*)))?/i, '').slice(4); | ||
} | ||
@@ -214,0 +217,0 @@ }); |
@@ -20,27 +20,10 @@ "use strict"; | ||
HttpService = HttpServiceInterface.inherit({ | ||
server: Type.OBJECT, | ||
config: Type.OBJECT | ||
server: Type.OBJECT | ||
}, { | ||
_construct: function HttpService(config) { | ||
this.config = { | ||
encoding: 'utf8' | ||
}; | ||
core.extend(this.config, config); | ||
_construct: function HttpService() { | ||
this.server = http.createServer(); | ||
}, | ||
/** | ||
* @since 0.0.1 | ||
* @author Igor Ivanovic | ||
* @method HttpService#getEncoding | ||
* | ||
* @description | ||
* Return encoding | ||
*/ | ||
getEncoding: function HttpService_getEncoding() { | ||
return this.config.encoding; | ||
}, | ||
/** | ||
* @since 0.0.1 | ||
* @author Igor Ivanovic | ||
* @method HttpService#on | ||
@@ -47,0 +30,0 @@ * |
@@ -44,3 +44,3 @@ "use strict"; | ||
encoding: Type.STRING, | ||
body: Type.STRING, | ||
body: Type.OBJECT, | ||
id: Type.STRING | ||
@@ -50,3 +50,3 @@ }, { | ||
this.isForwarded = false; | ||
this.body = ''; | ||
this.body = null; | ||
this.isERROR = false; | ||
@@ -376,6 +376,5 @@ // body and isForwarded can be overriden | ||
} | ||
this.request.setEncoding(this.encoding); | ||
// receive body as buffer | ||
this.request.on('data', function (body) { | ||
this.body += body; | ||
this.body = body; | ||
}.bind(this)); | ||
@@ -382,0 +381,0 @@ |
@@ -22,3 +22,3 @@ "use strict"; | ||
_invoke: function HttpServiceInterface() { | ||
["on", "listen", "close", "setTimeout", "getEncoding"].forEach(function (method) { | ||
["on", "listen", "close", "setTimeout"].forEach(function (method) { | ||
if (!(method in this)) { | ||
@@ -25,0 +25,0 @@ throw new error.DataError({method: method}, 'HttpServiceInterface: missing method in HttpService object'); |
@@ -5,3 +5,3 @@ { | ||
"description": "Powerful lightweight mvc framework for nodejs", | ||
"version": "0.1.0-beta-62", | ||
"version": "0.1.0-beta-63", | ||
"dependencies" : { | ||
@@ -8,0 +8,0 @@ "mongoose": "3.8.x", |
104
README.md
@@ -5,5 +5,5 @@ | ||
Powerful lightweight mvc framework for nodejs inspired by [Yii](http://www.yiiframework.com/) | ||
Powerful lightweight mvc framework for nodejs. | ||
Mvcjs is a first nodejs framework which supports modules as bundles! | ||
Mvcjs is a first nodejs framework which supports modules as bundles and a first node.js framework with dependency injection! | ||
@@ -22,105 +22,9 @@ Features | ||
[Demo application](https://github.com/igorzg/mvcjs-testapp) | ||
[Docs and live app](http://mvcjs.igorivanovic.info) | ||
Getting started | ||
==== | ||
npm install mvcjs | ||
index.js | ||
```javascript | ||
var di = require('mvcjs'); | ||
var framework = di.load('bootstrap'); | ||
framework.setBasePath(__dirname); | ||
framework.init('app/', 'env.json'); | ||
``` | ||
[Demo application](https://github.com/igorzg/mvcjs-testapp) | ||
app/env.json | ||
```json | ||
{ | ||
"aliases": [ | ||
{ | ||
"key": "assetsPath", | ||
"value": "@{basePath}/assets" | ||
} | ||
], | ||
"components": [ | ||
{ | ||
"name": "core/logger", | ||
"enabled": true, | ||
"write": true, | ||
"publish": true, | ||
"console": true, | ||
"port": 9001, | ||
"file": "server.log" | ||
}, | ||
{ | ||
"name": "core/router", | ||
"errorRoute": "core/error" | ||
}, | ||
{ | ||
"name": "core/favicon", | ||
"path": "@{basePath}/favicon.ico" | ||
}, | ||
{ | ||
"name": "core/view", | ||
"views": "@{appPath}/views/", | ||
"theme": "default", | ||
"cache": true | ||
}, | ||
{ | ||
"name": "core/assets", | ||
"path": "@{basePath}/storage/", | ||
"hook": "^\\/assets" | ||
}, | ||
{ | ||
"name": "db/mongo", | ||
"connection": "mongodb://localhost/testdb" | ||
} | ||
], | ||
"config": "config-test.js", | ||
"assetsPath": "@{assetsPath}", | ||
"port": 9000 | ||
} | ||
``` | ||
[Docs and live app](http://mvcjs.igorivanovic.info) | ||
app/config-test.js | ||
```javascript | ||
module.exports = function (componet, di) { | ||
"use strict"; | ||
var viewLoader, router, | ||
logger = componet.get('core/logger'), | ||
loggerModel = di.load('@{modelsPath}/logger'); | ||
viewLoader = componet.get('core/view'); | ||
viewLoader.setTheme('home'); | ||
// bind logger hook | ||
logger.addHook(loggerModel.save.bind(loggerModel)); | ||
router = componet.get('core/router'); | ||
router.add([ | ||
{ | ||
pattern: 'home/<action>', | ||
route: 'home/<action>' | ||
}, | ||
{ | ||
pattern: 'posts/<action:(create|update|delete)>', | ||
route: 'posts/<action>', | ||
method: ['GET', 'POST'] | ||
}, | ||
{ | ||
pattern: 'user/<id:(\\d+)>', | ||
route: 'user/view' | ||
} | ||
]); | ||
router.add({ | ||
pattern: '/', | ||
route: 'home/index' | ||
}); | ||
}; | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145964
4694
29