Eliminando codigo redundante v3

This commit is contained in:
Juan Ferrer Toribio 2017-10-13 16:23:00 +02:00
parent 4267b5fe0a
commit 5f1066ff03
91 changed files with 125 additions and 1927 deletions

View File

@ -16,3 +16,5 @@ rules:
camelcase: 0
default-case: 0
no-eq-null: 0
no-console: 0
no-warning-comments: 0

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
node_modules
spliting.js
build
npm-debug.log
debug.log

2
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Iniciar",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/services/client/server/server.js",
"program": "${workspaceRoot}/services/auth/server/server.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",

View File

@ -1,20 +0,0 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log
db.json

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -8,20 +8,7 @@
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-context": "^3.1.0",
"md5": "^2.2.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"nsp": "^2.1.0"
"md5": "^2.2.1"
},
"repository": {
"type": "git",

View File

@ -1,4 +0,0 @@
module.exports = function(server) {
require('../../../service/boot/root.js')(server);
};

View File

@ -39,17 +39,19 @@ module.exports = function(app) {
return;
}
let loginUrl;
let apiKey;
let continueUrl;
try {
let query = url.parse(req.body.location, true).query;
loginUrl = applications[query.apiKey];
apiKey = query.apiKey;
continueUrl = query.continue;
} catch (e) {}
if (!loginUrl)
loginUrl = applications.default;
} catch (e) {
apiKey = 'default';
continueUrl = null;
}
loginUrl = applications[apiKey];
res.send(JSON.stringify({
token: token.id,
@ -58,7 +60,7 @@ module.exports = function(app) {
}));
}
function findCb(err, instance) {
if (!instance || instance.password !== md5(password)) {
if (err || !instance || instance.password !== md5(password)) {
badLogin();
return;
}

View File

@ -1,5 +0,0 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}

View File

@ -1,25 +1,3 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"aclErrorStatus": 403,
"logoutSessionsOnSensitiveChanges": true,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"handleErrors": false
},
"legacyExplorer": false
}
"port": 3000
}

View File

@ -1,19 +0,0 @@
{
"db": {
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,21 +0,0 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,10 +0,0 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}

View File

@ -1,52 +0,0 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": "*",
"credentials": true,
"maxAge": 86400
}
},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
}
},
"session": {},
"auth": {},
"parse": {
"body-parser#json":{}
},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"strong-error-handler": {}
}
}

View File

@ -1,19 +1,4 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../../service/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"user": {
"dataSource": "auth"
},

View File

@ -1,32 +1,5 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var express=require('express');
var path = require('path');
var app = module.exports = loopback();
var vnLoopback = require('../../loopback/server/server.js');
// modificado
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname,'../client'));
app.use(loopback.static(path.resolve(__dirname, '../client')));
var app = module.exports = vnLoopback(__dirname, true);
app.set('applications', require('./application.json'));
// fin
app.start = function() {
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server LOGIN listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
boot(app, __dirname, function(err) {
if (err) throw err;
if (require.main === module)
app.start();
});

View File

@ -1,20 +0,0 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log
db.json

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -1,17 +1,13 @@
module.exports = function (iban){
module.exports = function(iban) {
if (iban == null) return true;
if (typeof iban != 'string') return false;
//Se pasa a Mayusculas
iban = iban.toUpperCase();
//Se quita los blancos de principio y final.
iban = trim(iban);
iban = iban.replace(/\s/g, ""); //Y se quita los espacios en blanco dentro de la cadena
iban = iban.replace(/\s/g, "");
//La longitud debe ser siempre de 24 caracteres
if (iban.length != 24) {
return false;
return false;
}
// Se coge las primeras dos letras y se pasan a números
@ -19,27 +15,30 @@ module.exports = function (iban){
var letter2 = iban.substring(1, 2);
var num1 = getIbanNumber(letter1);
var num2 = getIbanNumber(letter2);
//Se sustituye las letras por números.
var isbanaux = String(num1) + String(num2) + iban.substring(2);
// Se mueve los 6 primeros caracteres al final de la cadena.
isbanaux = isbanaux.substring(6) + isbanaux.substring(0,6);
//Se calcula el resto, llamando a la función module97, definida más abajo
// Se sustituye las letras por números.
var isbanaux = String(num1) + String(num2) + iban.substring(2);
// Se mueve los 6 primeros caracteres al final de la cadena.
isbanaux = isbanaux.substring(6) + isbanaux.substring(0, 6);
// Se calcula el resto, llamando a la función module97, definida más abajo
var resto = module97(isbanaux);
if (resto == 1){
if (resto == 1) {
return true;
}else{
return false;
}
return false;
function module97(iban) {
var parts = Math.ceil(iban.length/7);
var parts = Math.ceil(iban.length / 7);
var remainer = "";
for (var i = 1; i <= parts; i++) {
remainer = String(parseFloat(remainer+iban.substr((i-1)*7, 7))%97);
remainer = String(parseFloat(remainer + iban.substr((i - 1) * 7, 7)) % 97);
}
return remainer;
}
@ -48,9 +47,7 @@ module.exports = function (iban){
return letters.search(letra) + 10;
}
function trim (text) {
return (text || "").replace( /^(\s|\u00A0)+|(\s|\u00A0)+$/g, "" );
function trim(text) {
return (text || "").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, "" );
}
}
};

View File

@ -1,31 +1,18 @@
{
"name": "vn-client",
"description": "Client service",
"version": "1.0.0",
"license": "GPL-3.0",
"main": "server/server.js",
"scripts": {
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"i18n": "^0.8.3",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-context": "^3.1.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"nsp": "^2.1.0"
},
"repository": {
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "GPL-3.0",
"description": "Client service"
"dependencies": {
"loopback-context": "^3.3.0"
}
}

View File

@ -1,4 +0,0 @@
module.exports = function(server) {
require('../../../service/boot/root.js')(server);
};

View File

@ -1,5 +0,0 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}

View File

@ -1,25 +1,3 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3002,
"aclErrorStatus": 403,
"logoutSessionsOnSensitiveChanges": true,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"handleErrors": false
},
"legacyExplorer": false
"port": 3002
}

View File

@ -1,31 +0,0 @@
{
"db": {
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,32 +0,0 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth":
{
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": ""
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,10 +0,0 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}

View File

@ -1,54 +0,0 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"./middleware/cors": {},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
},
"loopback-context#per-request": {
"params": {
"enableHttpContext": true
}
}
},
"session": {},
"auth": {
"loopback#token": {}
},
"auth:after": {
"./middleware/currentUser": {}
},
"parse": {},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"strong-error-handler": {}
}
}

View File

@ -1,15 +0,0 @@
var cors = require('cors');
var whitelist = ['http://localhost:8080'];
var corsOptions = {
origin: function(origin, callback){
var originIsWhitelisted = whitelist.indexOf(origin) !== -1;
callback(originIsWhitelisted ? null : 'Bad Request', originIsWhitelisted);
}
}
module.exports = function() {
return cors({origin: true});
};

View File

@ -1,13 +0,0 @@
module.exports = function(options) {
return function storeCurrentUser(req, res, next) {
if (!req.accessToken) {
return next();
}
let LoopBackContext = require('loopback-context');
let loopbackContext = LoopBackContext.getCurrentContext();
if (loopbackContext) {
loopbackContext.set('currentUser', req.accessToken.userId);
}
next();
};
};

View File

@ -1,4 +0,0 @@
module.exports = function() {
console.log('Date time middleware triggered.');
res.json({datetime: new Date()});
};

View File

@ -1,19 +1,4 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../../service/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"user": {
"dataSource": "auth"
},
@ -28,16 +13,13 @@
}
},
"ACL": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"RoleMapping": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Role": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Account": {
"dataSource": "auth"

View File

@ -1,44 +1,4 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = loopback();
/*i18n*/
var i18n = require("i18n");
i18n.configure({
directory: __dirname + '/i18n',
defaultLocale: "es"
});
/* Prueba i18n */
app.get('/prueba', function (req,res){
i18n.setLocale(req.get('Accept-Language').substring(0,2));
res.send(i18n.__("Hello"));
});
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
module.exports = vnLoopback(__dirname);

View File

@ -22,10 +22,11 @@ app.start = function() {
database.init();
database.testEmail();
console.log('Web server ' + settings.app().name.toUpperCase() + ' listening at: ' + servicePath);
console.log('Browse your REST API at: ' + servicePath + '/mailer');
let packageJson = require('./package.json');
console.log(`Web server ${packageJson.name} listening at: ${servicePath}`);
if (settings.app().debug) {
console.log(settings.app().name.toUpperCase() + ' service debug mode enabled');
console.log(`${packageJson.name} service debug mode enabled`);
}
});
return listener;

View File

@ -1,13 +0,0 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

View File

@ -1 +0,0 @@
/client/

View File

@ -1,3 +0,0 @@
{
"extends": "loopback"
}

View File

@ -1,19 +0,0 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -7,23 +7,6 @@
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"i18n": "^0.8.3",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-connector-remote": "^3.1.1",
"loopback-context": "^3.1.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"nsp": "^2.1.0"
},
"repository": {
"type": "git",
"url": "https://git.verdnatura.es/salix"

View File

@ -1,4 +0,0 @@
module.exports = function(server) {
require('../../../service/boot/root.js')(server);
};

View File

@ -1,5 +0,0 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}

View File

@ -1,22 +1,3 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3004,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"handleErrors": false
}
"port": 3004
}

View File

@ -1,36 +0,0 @@
{
"db": {
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"client": {
"name": "client",
"connector": "remote",
"url": "http://localhost:3002/api"
}
}

View File

@ -1,36 +0,0 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth":
{
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": ""
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"client": {
"name": "client",
"connector": "remote",
"url": "http://localhost:3002/api"
}
}

View File

@ -1,10 +0,0 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}

View File

@ -1,60 +0,0 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
},
"loopback-context#per-request": {
"params": {
"enableHttpContext": true
}
}
},
"session": {},
"auth": {
"loopback#token": {}
},
"auth:after": {
"./middleware/currentUser": {}
},
"parse": {},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"strong-error-handler": {}
}
}

View File

@ -1,13 +0,0 @@
module.exports = function(options) {
return function storeCurrentUser(req, res, next) {
if (!req.accessToken) {
return next();
}
let LoopBackContext = require('loopback-context');
let loopbackContext = LoopBackContext.getCurrentContext();
if (loopbackContext) {
loopbackContext.set('currentUser', req.accessToken.userId);
}
next();
};
};

View File

@ -1,19 +1,4 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../../service/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"user": {
"dataSource": "auth"
},
@ -28,67 +13,52 @@
}
},
"ACL": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"RoleMapping": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Role": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Account": {
"dataSource": "auth"
},
"Ticket": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"State":{
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"TicketState":{
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Warehouse":{
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Employee":{
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Client":{
"dataSource": "client",
"public": true
"dataSource": "client"
},
"Province":{
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Agency": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"FakeProduction": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Message": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"MessageInbox": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
},
"Route": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
}
}

View File

@ -1,29 +1,4 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = loopback();
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
module.exports = vnLoopback(__dirname);

View File

@ -1,19 +0,0 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -7,27 +7,10 @@
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"i18n": "^0.8.3",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-connector-remote": "^3.1.1",
"loopback-context": "^3.1.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"nsp": "^2.1.0"
},
"repository": {
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "GPL-3.0",
"description": "vn-route"
"description": "Routes administration"
}

View File

@ -1,4 +0,0 @@
module.exports = function(server) {
require('../../../service/boot/root.js')(server);
};

View File

@ -1,5 +0,0 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}

View File

@ -1,22 +1,3 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3005,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"handleErrors": false
}
"port": 3005
}

View File

@ -1,31 +0,0 @@
{
"db": {
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,31 +0,0 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth":
{
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": ""
},
"vn": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,10 +0,0 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}

View File

@ -1,60 +0,0 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
},
"loopback-context#per-request": {
"params": {
"enableHttpContext": true
}
}
},
"session": {},
"auth": {
"loopback#token": {}
},
"auth:after": {
"./middleware/currentUser": {}
},
"parse": {},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"strong-error-handler": {}
}
}

View File

@ -1,13 +0,0 @@
module.exports = function(options) {
return function storeCurrentUser(req, res, next) {
if (!req.accessToken) {
return next();
}
let LoopBackContext = require('loopback-context');
let loopbackContext = LoopBackContext.getCurrentContext();
if (loopbackContext) {
loopbackContext.set('currentUser', req.accessToken.userId);
}
next();
};
};

View File

@ -1,19 +1,4 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../../service/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"user": {
"dataSource": "auth"
},
@ -28,16 +13,13 @@
}
},
"ACL": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"RoleMapping": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Role": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Account": {
"dataSource": "auth"
@ -49,7 +31,6 @@
"dataSource": "vn"
},
"Agency": {
"dataSource": "vn",
"public": true
"dataSource": "vn"
}
}

View File

@ -1,29 +1,4 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = loopback();
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
module.exports = vnLoopback(__dirname);

View File

@ -1,19 +0,0 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}

View File

@ -8,20 +8,7 @@
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "^1.0.3",
"cookie-parser": "^1.4.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-context": "^3.1.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"nsp": "^2.1.0"
"cookie-parser": "^1.4.3"
},
"repository": {
"type": "git",
@ -29,4 +16,4 @@
},
"license": "GPL-3.0",
"description": "Salix application service"
}
}

View File

@ -1,4 +0,0 @@
module.exports = function(server) {
require ('../../../service/boot/root.js')(server);
};

View File

@ -1,7 +1,7 @@
module.exports = function (app) {
module.exports = function(app) {
let models = app.models;
app.get('/', function (req, res) {
app.get('/', function(req, res) {
let token = req.cookies.vnToken;
validateToken(token, function(isValid) {
if (isValid)
@ -11,7 +11,7 @@ module.exports = function (app) {
});
});
app.get('/acl', function(req, res){
app.get('/acl', function(req, res) {
let token = req.cookies.vnToken;
validateToken(token, function(isValid, token) {
if (isValid)
@ -19,95 +19,90 @@ module.exports = function (app) {
else
sendACL(res, {});
});
});
app.get('/login', function (req, res) {
app.get('/login', function(req, res) {
let token = req.query.token;
let continueUrl = req.query.continue;
validateToken(token, function(isValid) {
if (isValid) {
res.cookie('vnToken', token/*, {httpOnly: true}*/);
res.cookie('vnToken', token /* , {httpOnly: true} */);
res.redirect(continueUrl ? continueUrl : '/');
}
else
} else
redirectToAuth(res);
});
});
app.get('/logout', function (req, res) {
app.get('/logout', function(req, res) {
let token = req.cookies.vnToken;
models.User.logout(token, function() {
redirectToAuth(res);
});
});
function validateToken(tokenId, cb) {
function validateToken(tokenId, cb) {
models.AccessToken.findById(tokenId, function(err, token) {
if (token) {
token.validate (function (err, isValid) {
token.validate(function (err, isValid) {
cb(isValid === true, token);
});
}
else
} else
cb(false);
});
}
function sendUserRole(res, token){
if(token.userId){
function sendUserRole(res, token) {
if (token.userId) {
let query = {
"where": {
"principalId": token.userId,
"principalType": "USER"
},
"include": [{
"relation": "role",
"scope": {
"fields": ["name"]
}
}]
where: {
principalId: token.userId,
principalType: 'USER'
},
include: [{
relation: 'role',
scope: {
fields: ['name']
}
}]
};
models.RoleMapping.find(query, function(_, roles){
if(roles){
models.RoleMapping.find(query, function(_, roles) {
if (roles) {
var acl = {
userProfile: {},
roles: {}
};
Object.keys(roles).forEach(function(_, i){
if(roles[i].roleId){
Object.keys(roles).forEach(function(_, i) {
if (roles[i].roleId) {
let rol = roles[i].role();
acl.roles[rol.name] = true;
}
});
models.User.findById(token.userId, function(_, userProfile){
//acl.userProfile = userProfile;
models.User.findById(token.userId, function(_, userProfile) {
// acl.userProfile = userProfile;
acl.userProfile.id = userProfile.id;
acl.userProfile.username = userProfile.username;
acl.userProfile.warehouseId = 1;
sendACL(res, acl);
});
}
else
} else
sendACL(res, {});
});
}
else
} else
sendACL(res, {});
}
function redirectToAuth (res, continueUrl) {
function redirectToAuth(res, continueUrl) {
let authUrl = app.get('url auth');
let params = {
apiKey: app.get('api key'),
continue: continueUrl
};
res.clearCookie ('vnToken');
res.clearCookie('vnToken');
res.redirect(`${authUrl}/?${encodeUri(params)}`);
}
function sendACL(res, acl){
function sendACL(res, acl) {
let aclStr = JSON.stringify(acl);
res.header('Content-Type', 'application/javascript; charset=UTF-8');
res.send(`(function(window){window.salix = window.salix || {}; window.salix.acl = window.salix.acl || {}; window.salix.acl = ${aclStr}; })(window)`);

View File

@ -1,5 +0,0 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}

View File

@ -1,25 +1,3 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3001,
"aclErrorStatus": 403,
"logoutSessionsOnSensitiveChanges": true,
"remoting": {
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"handleErrors": false
},
"legacyExplorer": false
"port": 3001
}

View File

@ -1,18 +0,0 @@
{
"db": {
"name": "db",
"connector": "memory"
},
"auth": {
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": "",
"connectTimeout": 20000,
"acquireTimeout": 20000
}
}

View File

@ -1,19 +0,0 @@
{
"db":
{
"name": "db",
"connector": "memory",
"file": "db.json"
},
"auth":
{
"name": "mysql",
"connector": "mysql",
"database": "salix",
"debug": false,
"host": "localhost",
"port": 3306,
"username": "root",
"password": ""
}
}

View File

@ -1,10 +0,0 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}

View File

@ -1,50 +0,0 @@
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
}
},
"session": {},
"auth": {},
"parse": {},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"strong-error-handler": {}
}
}

View File

@ -1,19 +1,4 @@
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../../service/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"user": {
"dataSource": "auth"
},
@ -28,15 +13,15 @@
}
},
"ACL": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"RoleMapping": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Role": {
"dataSource": "auth",
"public": false
"dataSource": "auth"
},
"Account": {
"dataSource": "auth"
}
}

View File

@ -1,40 +1,11 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var path = require('path');
var cookieParser = require('cookie-parser');
var vnLoopback = require('../../loopback/server/server.js');
var app = module.exports = loopback();
var app = module.exports = vnLoopback(__dirname, true);
// TODO: ver donde se almacena
app.set('api key','salix')
app.set('api key', 'salix');
app.set('url auth', '/auth');
app.set('view engine', 'ejs');
app.set('views',path.join(__dirname,'../client'));
app.use(loopback.static(path.resolve(__dirname, '../client')));
app.use(cookieParser());
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});

View File

@ -1,42 +0,0 @@
module.exports = function(app) {
let models = app.models();
models.forEach(function(model) {
let settings = model.settings;
let acls = settings.acls;
if (!acls)
model.settings.acls = acls = [];
acls.push({
accessType: '*',
principalType: 'ROLE',
principalId: '$everyone',
permission: 'DENY'
});
acls.push({
accessType: '*',
principalType: 'ROLE',
principalId: 'root',
permission: 'ALLOW'
});
if (settings.validateUpsert === undefined)
settings.validateUpsert = true;
});
app.enableAuth();
var router = app.loopback.Router();
router.get('/status', app.loopback.status());
app.use(router);
require('./validations')(app);
/*
let ds = app.dataSources.auth;
//ds.automigrate(function() {
ds.autoupdate(function() {
console.log('Tables migrated!');
});
*/
};

View File

@ -1,58 +0,0 @@
module.exports = function(server) {
function toJson(object) {
let json = {};
for (let prop in object) {
let value = object[prop];
switch (typeof value) {
case 'object':
if (value instanceof RegExp)
json[prop] = value.source;
break;
case 'function':
json[prop] = value.toString();
break;
default:
json[prop] = value;
}
}
return json;
}
server.get('/validations', function(req, res) {
let json = {};
let models = server.models;
for (let modelName in models) {
let model = models[modelName];
let validations = model.validations;
let jsonValidations = {};
for (let fieldName in validations) {
let jsonField = [];
for (let validation of validations[fieldName]) {
let options = validation.options;
if ((options && options.async) ||
(validation.validation == 'custom' && !validation.isExportable))
continue;
jsonField.push(toJson(validation));
}
jsonValidations[fieldName] = jsonField;
}
json[modelName] = {
properties: model.definition.rawProperties,
validations: jsonValidations
};
}
res.set('Content-Type', 'application/json');
res.send(JSON.stringify(json));
});
};

View File

@ -1,4 +0,0 @@
module.exports = Agency => {
let serverFilter = {where: {isManaged: {neq: 0}}};
Agency.defineScope(serverFilter);
};

View File

@ -1,3 +0,0 @@
module.exports = function(Self) {
Self.defineScope({where: {isManaged: {neq: 0}}});
};

View File

@ -1,7 +0,0 @@
module.exports = function(Account) {
// Validations
Account.validatesUniquenessOf('name', {
message: 'Ya existe un usuario con ese nombre'
});
};

View File

@ -1,32 +0,0 @@
{
"name": "Account",
"base": "PersistedModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "number",
"required": true
},
"name": {
"type": "string",
"required": true
},
"password": {
"type": "string",
"required": true
},
"active": {
"type": "boolean"
},
"email": {
"type": "string",
"required": true
},
"created": {
"type": "date"
},
"updated": {
"type": "date"
}
}
}

View File

@ -1,3 +0,0 @@
module.exports = function(Self) {
require('../methods/agency/list.js')(Self);
};

View File

@ -1,15 +0,0 @@
{
"name": "Agency",
"base": "VnModel",
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"name": {
"type": "String",
"required": false
}
}
}

View File

@ -1,42 +0,0 @@
{
"name": "Country",
"base": "VnModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
},
"inCee": {
"type": "Number"
},
"code": {
"type": "string"
}
},
"relations": {
"currency": {
"type": "belongsTo",
"model": "Currency",
"foreignKey": "currencyFk"
},
"realCountry": {
"type": "belongsTo",
"model": "Country",
"foreignKey": "realCountryFk"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -1,26 +0,0 @@
{
"name": "Employee",
"base": "VnModel",
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
},
"surname": {
"type": "string",
"required": true
}
},
"relations": {
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
}
}
}

View File

@ -1,41 +0,0 @@
{
"name": "Province",
"base": "VnModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
}
},
"relations": {
"country": {
"type": "belongsTo",
"model": "Country",
"foreignKey": "countryFk"
},
"warehouse": {
"type": "belongsTo",
"model": "Warehouse",
"foreignKey": "warehouseFk"
},
"zone": {
"type": "belongsTo",
"model": "Zone",
"foreignKey": "zoneFk"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -1,14 +0,0 @@
{
"name": "user",
"base": "User",
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"username":{
"type": "string"
}
}
}

View File

@ -1,220 +0,0 @@
module.exports = function(Self) {
Self.setup = function() {
Self.super_.setup.call(this);
let disableMethods = {
create: true,
replaceOrCreate: true,
patchOrCreate: true,
upsert: true,
updateOrCreate: true,
exists: true,
find: true,
findOne: true,
findById: true,
deleteById: true,
replaceById: true,
updateAttributes: false,
createChangeStream: true,
updateAll: true,
upsertWithWhere: true,
count: true
};
for (let method in disableMethods) {
// this.disableRemoteMethod(method, disableMethods[method]);
}
};
Self.defineScope = function(serverFilter) {
this.remoteMethodCtx('list', {
accepts: [
{
arg: 'filter',
type: 'object',
description: 'Filter defining where'
}
],
returns: {
type: [this.modelName],
root: true
},
http: {
verb: 'get',
path: '/list'
}
});
this.list = function(ctx, clientFilter, cb) {
var clientFields = (clientFilter && clientFilter.fields) ? clientFilter.fields : [];
var serverFields = (serverFilter && serverFilter.fields) ? serverFilter.fields : [];
var fields = clientFields.filter(itemC => {
return serverFields.some(itemS => itemS === itemC);
});
var and = [];
(clientFilter && clientFilter.where) && and.push(clientFilter.where);
(serverFilter && serverFilter.where) && and.push(serverFilter.where);
var order;
var limit;
if (clientFilter && clientFilter.order)
order = clientFilter.order;
else if (serverFilter && serverFilter.order)
order = serverFilter.order;
if (serverFilter && serverFilter.limit)
limit = serverFilter.limit;
else if (clientFilter && clientFilter.limit)
limit = clientFilter.limit;
var filter = {order: order, limit: limit};
filter.where = (and.length > 0) && {and: and};
filter.fields = fields;
this.find(filter, function(err, states) {
(err) ? cb(err, null) : cb(null, states);
});
};
};
Self.rawSql = function(query, params, cb) {
var connector = this.dataSource.connector;
return new Promise(function(resolve, reject) {
connector.execute(query, params, function(error, response) {
if (error && !reject)
cb(error, null);
else if (error && reject)
reject(error);
else
resolve(response);
});
});
};
Self.remoteMethodCtx = function(methodName, args) {
var ctx = {
arg: 'context',
type: 'object',
http: function(ctx) {
return ctx;
}
};
if (args.accepts === undefined)
args.accepts = [];
else if (!Array.isArray(args.accepts))
args.accepts = [args.accepts];
args.accepts.unshift(ctx);
this.remoteMethod(methodName, args);
};
Self.connectToService = function(ctx, dataSource) {
this.app.dataSources[dataSource].connector.remotes.auth = {
bearer: new Buffer(ctx.req.accessToken.id).toString('base64'),
sendImmediately: true
};
};
Self.disconnectFromService = function(dataSource) {
this.app.dataSources[dataSource].connector.remotes.auth = {
bearer: new Buffer("").toString('base64'),
sendImmediately: true
};
};
Self.installMethod = function(methodName, filterCb) {
this.remoteMethod(methodName, {
description: 'List items using a filter',
accessType: 'READ',
accepts: [
{
arg: 'filter',
type: 'object',
required: true,
description: 'Filter defining where',
http: function(ctx) {
return ctx.req.query;
}
}
],
returns: {
arg: 'data',
type: [this.modelName],
root: true
},
http: {
verb: 'get',
path: `/${methodName}`
}
});
this[methodName] = (params, cb) => {
let filter = removeEmpty(filterCb(params));
var response = {};
function returnValues() {
if (response.instances !== undefined && response.count !== undefined)
cb(null, response);
}
function error() {
cb(null, response);
}
this.find(filter, function(err, instances) {
if (err) {
error();
} else {
response.instances = instances;
returnValues();
}
});
this.count(filter.where, function(err, totalCount) {
if (err) {
error();
} else {
response.count = totalCount;
returnValues();
}
});
};
};
Self.validateBinded = function(propertyName, validatorFn, options) {
var customValidator = function(err) {
if (!validatorFn(this[propertyName])) err();
};
options.isExportable = true;
options.bindedFunction = validatorFn;
this.validate(propertyName, customValidator, options);
};
};
function removeEmpty(o) {
if (Array.isArray(o)) {
let array = [];
for (let item of o) {
let i = removeEmpty(item);
if (!isEmpty(item))
array.push(item);
}
if (array.length > 0)
return array;
} else if (typeof o === 'object') {
let object = {};
for (let key in o) {
let i = removeEmpty(o[key]);
if (!isEmpty(i))
object[key] = i;
}
if (Object.keys(object).length > 0)
return object;
} else if (!isEmpty(o))
return o;
return undefined;
}
function isEmpty(value) {
return value === undefined || value === "";
}

View File

@ -1,4 +0,0 @@
{
"name": "VnModel",
"base": "PersistedModel"
}

View File

@ -1,4 +0,0 @@
module.exports = function(Self) {
require('../methods/warehouse/list.js')(Self);
};

View File

@ -1,31 +0,0 @@
{
"name": "Warehouse",
"base": "VnModel",
"properties": {
"id": {
"id": true,
"type": "Number",
"forceId": false
},
"name": {
"type": "String"
},
"inventory": {
"type": "Number"
},
"isManaged":{
"type":"boolean"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
],
"scopes" : {
"production" : {"where": {"isManaged": {"neq": 0}}}
}
}