New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lark-mvc

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lark-mvc - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

examples/models/pageServices/simplified.js

63

index.js

@@ -11,9 +11,43 @@ var path = require('path');

var larkMVC = function(options, lark){
var path = (!options || !options.path) ? 'models': options.path
if (!options || !options.path) {
var _path = 'models'
}else{
var _path = options.path
}
if (process.mainModule) {
_path = path.join(path.dirname(process.mainModule.filename), _path);
}
if (_path[_path.length - 1] !== '/') {
_path += '/';
}
rd.eachFileFilterSync(_path, /\.js$/, function (file) {
if (0 !== file.indexOf(_path)) {
throw new Error("File path " + file + " not expected, should be under " + _path);
}
var filename = path.basename(file)
if (filename && filename[0] === '.') {
return;
}
var relativePath = file.slice(_path.length);
var _pathsplit = relativePath.split('/');
if (_pathsplit.length <= 1) {
throw new Error('Invalid model path : ' + _path);
}
var filename = _pathsplit[_pathsplit.length - 1];
_pathsplit[_pathsplit.length - 1] = path.basename(filename, path.extname(filename));
rd.eachFileFilterSync(path, /\.js$/, function (file) {
var func = require(file)
if (func instanceof Function){
func(layerproxy, lark)
var modelproxy = createModel(layerproxy, _pathsplit);
var model = require(file);
if (model instanceof Function) {
return model(layerproxy, lark);
}
else if (model instanceof Object && !Array.isArray(model)) {
for (var property in model) {
if (!!modelproxy[property]) {
throw new Error('Property ' + property + ' in mvc.xxx in use!');
}
modelproxy[property] = model[property];
}
}
});

@@ -26,4 +60,23 @@ return function*(next) {

function createModel (layerproxy, _pathsplit, type) {
var type = type || _pathsplit.shift();
var name = _pathsplit.join('/');
switch (type) {
case 'dao' :
type = 'daoService';
break;
case 'dataServices' :
type = 'dataService';
break;
case 'pageServices' :
type = 'pageService';
break;
default :
throw new Error('Unknown model type ' + type);
}
return layerproxy[type].create(name);
}
var output = layerproxy;
output.middleware = larkMVC
module.exports = output

2

package.json
{
"name": "lark-mvc",
"version": "0.4.2",
"version": "0.4.3",
"description": "MVC for building web server with lark.js",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc