Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
d66fed5a3d
|
@ -16,3 +16,5 @@ rules:
|
|||
camelcase: 0
|
||||
default-case: 0
|
||||
no-eq-null: 0
|
||||
no-console: 0
|
||||
no-warning-comments: 0
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
node_modules
|
||||
spliting.js
|
||||
build
|
||||
npm-debug.log
|
||||
debug.log
|
||||
|
|
|
@ -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}",
|
||||
|
|
|
@ -33,11 +33,14 @@ describe('Client', () => {
|
|||
it(`should request to GET the client notes`, () => {
|
||||
let controller = $componentController('vnClientNotes', {$httpBackend: $httpBackend, $state: $state});
|
||||
controller.client = {id: '1234'};
|
||||
let json = JSON.stringify({where: {clientFk: '1234'}, order: 'created DESC'});
|
||||
$httpBackend.when('GET', `/client/api/clientObservations?filter=${json}`).respond('ok');
|
||||
$httpBackend.expectGET(`/client/api/clientObservations?filter=${json}`, {Accept: 'application/json, text/plain, */*'});
|
||||
let jsonString = JSON.stringify({where: {clientFk: '1234'}, order: 'created DESC'});
|
||||
let json = {data: 'some data'};
|
||||
$httpBackend.when('GET', `/client/api/clientObservations?filter=${jsonString}`).respond(json);
|
||||
$httpBackend.expectGET(`/client/api/clientObservations?filter=${jsonString}`, {Accept: 'application/json, text/plain, */*'});
|
||||
controller.getObservation();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.observations).toEqual(json);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ describe('Component vnAutocomplete', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('findItem()', () => {
|
||||
describe('findItems()', () => {
|
||||
it(`should return items empty array if the controller does not provide a url and have no items defined`, () => {
|
||||
let controller = $componentController('vnIconMenu', {$scope, $element, $httpBackend, $timeout});
|
||||
controller.findItems('some search value');
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Component vnDropDown', () => {
|
|||
|
||||
beforeEach(angular.mock.inject((_$componentController_, _$timeout_, _$filter_) => {
|
||||
$componentController = _$componentController_;
|
||||
$element = angular.element('<div></div>');
|
||||
$element = angular.element('<div><ul><li></li></ul></div>');
|
||||
$timeout = _$timeout_;
|
||||
$filter = _$filter_;
|
||||
}));
|
||||
|
@ -268,7 +268,7 @@ describe('Component vnDropDown', () => {
|
|||
expect(controller._activeOption).toEqual(0);
|
||||
});
|
||||
|
||||
it(`should call clearSearch() Esc key is pressed and take off 1 from _activeOption`, () => {
|
||||
it(`should call clearSearch() Esc key is pressed and add up 1 to _activeOption`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
controller.items = [{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce'}, {id: 3, name: 'Logan'}, {id: 4, name: 'Wolverine'}];
|
||||
spyOn(controller, 'setScrollPosition');
|
||||
|
@ -284,4 +284,77 @@ describe('Component vnDropDown', () => {
|
|||
expect(controller._activeOption).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setScrollPosition()', () => {
|
||||
it(`should call child.scrollIntoView if defined `, () => {
|
||||
$element[0].firstChild.setAttribute('class', 'dropdown');
|
||||
let child = $element[0].firstChild.firstChild;
|
||||
child.scrollIntoView = () => {};
|
||||
spyOn(child, 'scrollIntoView');
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
controller._activeOption = 0;
|
||||
controller.setScrollPosition();
|
||||
|
||||
expect(child.scrollIntoView).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectItem()', () => {
|
||||
it(`should pass item to selected and set controller._show to false`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
let item = {id: 1, name: 'Batman'};
|
||||
controller.selectItem(item);
|
||||
|
||||
expect(controller.selected).toEqual(item);
|
||||
expect(controller._show).toEqual(false);
|
||||
});
|
||||
|
||||
it(`should pass item to selected and set controller._show to true if the controller.multiple is defined`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
let item = {id: 1, name: 'Batman'};
|
||||
controller.multiple = true;
|
||||
controller.selectItem(item);
|
||||
|
||||
expect(controller.selected).toEqual(item);
|
||||
expect(controller._show).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('loadItems()', () => {
|
||||
it(`should set controller._show to true`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
controller.loadItems();
|
||||
|
||||
expect(controller._show).toEqual(true);
|
||||
});
|
||||
|
||||
it(`should call loadMore() and then set controller._show to true`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter}, {showLoadMore: () => {}, loadMore: () => {}});
|
||||
spyOn(controller, 'loadMore');
|
||||
controller.loadItems();
|
||||
|
||||
expect(controller._show).toEqual(true);
|
||||
expect(controller.loadMore).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onInit()', () => {
|
||||
it(`should add an event listener to the parent element`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
spyOn(controller.parent, 'addEventListener');
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.parent.addEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onDestroy()', () => {
|
||||
it(`should remove an event listener from the parent element`, () => {
|
||||
let controller = $componentController('vnDropDown', {$element, $timeout, $filter});
|
||||
spyOn(controller.parent, 'removeEventListener');
|
||||
controller.$onDestroy();
|
||||
|
||||
expect(controller.parent.removeEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
import './grid-header.js';
|
||||
|
||||
describe('Component vnGridHeader', () => {
|
||||
let $componentController;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(_$componentController_ => {
|
||||
$componentController = _$componentController_;
|
||||
}));
|
||||
|
||||
describe('selectColum()', () => {
|
||||
it(`should set controller currentColumn to equal the argument received`, () => {
|
||||
let controller = $componentController('vnGridHeader', {});
|
||||
let col = {columnStuff: 'some stuff'};
|
||||
controller.selectColum(col);
|
||||
|
||||
expect(controller.currentColumn).toEqual(col);
|
||||
});
|
||||
|
||||
it(`should set controller currentColumn.order to undefined then set currentColumn to equal the argument received`, () => {
|
||||
let controller = $componentController('vnGridHeader', {});
|
||||
controller.currentColumn = {field: 'some field', order: 'ordered'};
|
||||
let col = {columnStuff: 'some stuff'};
|
||||
controller.selectColum(col);
|
||||
|
||||
expect(controller.currentColumn.order).not.toBeDefined();
|
||||
expect(controller.currentColumn).toEqual(col);
|
||||
});
|
||||
|
||||
it(`should set controller currentColumn.order to undefined then call onOrder passing currentColumn as argument`, () => {
|
||||
let controller = $componentController('vnGridHeader', {});
|
||||
controller.onOrder = () => {};
|
||||
spyOn(controller, 'onOrder');
|
||||
let col = {columnStuff: 'some stuff'};
|
||||
controller.selectColum(col);
|
||||
|
||||
expect(controller.currentColumn).toEqual(col);
|
||||
expect(controller.onOrder).toHaveBeenCalledWith(col);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -38,7 +38,8 @@ export default class MultiCheck {
|
|||
let checked;
|
||||
if (this.type.id && this.type.id !== 'all' && this.type.id !== 'any') {
|
||||
if (this.type.id.length > 3 && this.type.id.substr(0, 3) === 'no-') {
|
||||
checked = el[this.type.id.replace('no-', '')] == null;
|
||||
let label = this.type.id.replace('no-', '');
|
||||
checked = el[label] == null;
|
||||
} else if (this.type.id.length > 6 && this.type.id.substr(0, 6) === 'equal-') {
|
||||
let label = this.type.id.replace('equal-', '');
|
||||
checked = (el[label] && el[label] === this.type.name);
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
import './multi-check.js';
|
||||
|
||||
describe('Component vnMultiCheck', () => {
|
||||
let $componentController;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(_$componentController_ => {
|
||||
$componentController = _$componentController_;
|
||||
}));
|
||||
|
||||
describe('models()', () => {
|
||||
it(`should set controller _models property with the argument received`, () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
let argument = 'I am the model';
|
||||
controller.models = argument;
|
||||
|
||||
expect(controller._models).toEqual(argument);
|
||||
});
|
||||
});
|
||||
|
||||
describe('checkAll()', () => {
|
||||
it(`should set controller _checkAll property with the argument received then call switchChecks()`, () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
let argument = 'I am the model';
|
||||
spyOn(controller, 'switchChecks');
|
||||
controller.checkAll = argument;
|
||||
|
||||
expect(controller._checkAll).toEqual(argument);
|
||||
expect(controller.switchChecks).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('switchChecks()', () => {
|
||||
it(`should set checked property inside each existing elemenet when begings with no-`, () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'no-name'};
|
||||
controller.models = [
|
||||
{name: 'name'},
|
||||
{name: null}
|
||||
];
|
||||
|
||||
expect(controller._models[0].checked).not.toBeDefined();
|
||||
expect(controller._models[1].checked).not.toBeDefined();
|
||||
controller._checkAll = 1;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
expect(controller._models[1].checked).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should set checked property inside each existing elemenet when begings with equal-`, () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'equal-name', name: 'name'};
|
||||
controller.models = [
|
||||
{name: null},
|
||||
{name: 'name'}
|
||||
];
|
||||
|
||||
expect(controller._models[0].checked).not.toBeDefined();
|
||||
expect(controller._models[1].checked).not.toBeDefined();
|
||||
controller._checkAll = 1;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
expect(controller._models[1].checked).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should set checked property inside each existing elemenet when begings with anything but any, all, no- or equal-`, () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'name'};
|
||||
controller.models = [
|
||||
{name: null},
|
||||
{name: 'name'}
|
||||
];
|
||||
|
||||
expect(controller._models[0].checked).not.toBeDefined();
|
||||
expect(controller._models[1].checked).not.toBeDefined();
|
||||
controller._checkAll = 1;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
expect(controller._models[1].checked).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('when id is any', () => {
|
||||
it('should set element checked property based on controller._checkAll', () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'any'};
|
||||
controller.models = [
|
||||
{name: 'name'}
|
||||
];
|
||||
|
||||
expect(controller._models[0].checked).not.toBeDefined();
|
||||
controller._checkAll = 1;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeTruthy();
|
||||
controller._checkAll = 0;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
controller._checkAll = 2;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when id is all', () => {
|
||||
it('should set element checked property based on controller._checkAll property', () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'all'};
|
||||
controller.models = [
|
||||
{name: 'name'}
|
||||
];
|
||||
|
||||
expect(controller._models[0].checked).not.toBeDefined();
|
||||
controller._checkAll = 1;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeTruthy();
|
||||
controller._checkAll = 0;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
controller._checkAll = 2;
|
||||
controller.switchChecks();
|
||||
|
||||
expect(controller._models[0].checked).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it('should set controller.type to empty object and checkAll to zero', () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'all'};
|
||||
controller._checkAll = 1;
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.type).toEqual({});
|
||||
expect(controller._checkAll).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('$doCheck()', () => {
|
||||
it('should set controller.type to empty object and checkAll based on controller.type.id', () => {
|
||||
let controller = $componentController('vnMultiCheck', {});
|
||||
controller.type = {id: 'all'};
|
||||
controller._checkAll = 0;
|
||||
controller.$doCheck();
|
||||
|
||||
expect(controller.type).toEqual({});
|
||||
expect(controller._checkAll).toEqual(1);
|
||||
controller.type = {id: 'any'};
|
||||
controller.$doCheck();
|
||||
|
||||
expect(controller.type).toEqual({});
|
||||
expect(controller._checkAll).toEqual(0);
|
||||
controller.type = {id: 'any other id name'};
|
||||
controller.$doCheck();
|
||||
|
||||
expect(controller.type).toEqual({});
|
||||
expect(controller._checkAll).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,65 @@
|
|||
import './spinner.js';
|
||||
|
||||
describe('Component vnSpinner', () => {
|
||||
let $componentController;
|
||||
let $scope;
|
||||
let $element;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
||||
$componentController = _$componentController_;
|
||||
$scope = $rootScope.$new();
|
||||
$element = angular.element('<div><div></div></div>');
|
||||
}));
|
||||
|
||||
describe('enable()', () => {
|
||||
it(`should call start() based on a boolean value passed as argument`, () => {
|
||||
let controller = $componentController('vnSpinner', {$scope, $element});
|
||||
spyOn(controller, 'start');
|
||||
spyOn(controller, 'stop');
|
||||
controller.enable = true;
|
||||
|
||||
expect(controller.start).toHaveBeenCalledWith();
|
||||
expect(controller.stop).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it(`should call stop() based on a boolean value passed as argument`, () => {
|
||||
let controller = $componentController('vnSpinner', {$scope, $element});
|
||||
spyOn(controller, 'start');
|
||||
spyOn(controller, 'stop');
|
||||
controller.enable = false;
|
||||
|
||||
expect(controller.start).not.toHaveBeenCalledWith();
|
||||
expect(controller.stop).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('start()', () => {
|
||||
it(`should call start() on the controller.materialSpinner then set controllers._enable to be truthy`, () => {
|
||||
let controller = $componentController('vnSpinner', {$scope, $element});
|
||||
controller.spinner = {MaterialSpinner: {start: () => {}}};
|
||||
spyOn(controller.spinner.MaterialSpinner, 'start');
|
||||
controller._enable = false;
|
||||
controller.start();
|
||||
|
||||
expect(controller.spinner.MaterialSpinner.start).toHaveBeenCalledWith();
|
||||
expect(controller._enable).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('stop()', () => {
|
||||
it(`should call stop() on the controller.materialSpinner then set controllers._enable to be truthy`, () => {
|
||||
let controller = $componentController('vnSpinner', {$scope, $element});
|
||||
controller.spinner = {MaterialSpinner: {stop: () => {}}};
|
||||
spyOn(controller.spinner.MaterialSpinner, 'stop');
|
||||
controller._enable = true;
|
||||
controller.stop();
|
||||
|
||||
expect(controller.spinner.MaterialSpinner.stop).toHaveBeenCalledWith();
|
||||
expect(controller._enable).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -59,7 +59,7 @@ export default class Watcher extends Component {
|
|||
* Submits the data and goes back in the history.
|
||||
*/
|
||||
submitBack() {
|
||||
this.submit().then(
|
||||
return this.submit().then(
|
||||
() => this.window.history.back()
|
||||
);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ export default class Watcher extends Component {
|
|||
* @param {String} state The state name
|
||||
*/
|
||||
submitGo(state) {
|
||||
this.submit().then(
|
||||
return this.submit().then(
|
||||
() => this.$state.go(state)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
import './watcher.js';
|
||||
|
||||
describe('Component vnWatcher', () => {
|
||||
let $componentController;
|
||||
let $scope;
|
||||
let $element;
|
||||
let $state;
|
||||
let $transitions;
|
||||
let $httpBackend;
|
||||
let vnApp;
|
||||
let $translate;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_, _$transitions_, _$httpBackend_, _vnApp_, _$translate_) => {
|
||||
$componentController = _$componentController_;
|
||||
$scope = $rootScope.$new();
|
||||
$element = angular.element('<div></div>');
|
||||
$state = _$state_;
|
||||
vnApp = _vnApp_;
|
||||
$transitions = _$transitions_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$translate = _$translate_;
|
||||
}));
|
||||
|
||||
describe('$onInit()', () => {
|
||||
it(`should call fetchData() if controllers get and url properties are defined`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.get = () => {};
|
||||
controller.url = 'test.com';
|
||||
spyOn(controller, 'fetchData');
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.fetchData).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it(`should throw an error if $onInit is called without url defined`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.get = () => {};
|
||||
|
||||
expect(function() {
|
||||
controller.$onInit();
|
||||
}).toThrow(new Error('Error: Parameter url ommitted'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it(`should call updateOriginalData() if controllers data is defined`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.data = [];
|
||||
spyOn(controller, 'updateOriginalData');
|
||||
controller.$onChanges();
|
||||
|
||||
expect(controller.updateOriginalData).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('$onDestroy()', () => {
|
||||
it(`should call deregisterCallback()`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
spyOn(controller, 'deregisterCallback');
|
||||
controller.$onDestroy();
|
||||
|
||||
expect(controller.deregisterCallback).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchData()', () => {
|
||||
it(`should perform a query then store the received data into controller.data and call updateOriginalData()`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
spyOn(controller, 'updateOriginalData');
|
||||
let json = {data: 'some data'};
|
||||
controller.data = [1];
|
||||
controller.idField = 0;
|
||||
controller.url = 'test.com';
|
||||
$httpBackend.whenGET('test.com/1').respond(json);
|
||||
$httpBackend.expectGET('test.com/1');
|
||||
controller.fetchData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.data).toEqual({data: 'some data'});
|
||||
expect(controller.updateOriginalData).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('submitBack()', () => {
|
||||
it(`should call controller.window.history.back() function after calling controllers submit() function`, done => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
spyOn(controller, 'submit').and.returnValue(Promise.resolve());
|
||||
spyOn(controller.window.history, 'back');
|
||||
controller.submitBack()
|
||||
.then(() => {
|
||||
expect(controller.submit).toHaveBeenCalledWith();
|
||||
expect(controller.window.history.back).toHaveBeenCalledWith();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('submitGo()', () => {
|
||||
it(`should call controller.$state.go() function after calling controllers submit() function`, done => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
spyOn(controller, 'submit').and.returnValue(Promise.resolve());
|
||||
spyOn(controller.$state, 'go');
|
||||
let state = 'the state';
|
||||
controller.submitGo(state)
|
||||
.then(() => {
|
||||
expect(controller.submit).toHaveBeenCalledWith();
|
||||
expect(controller.$state.go).toHaveBeenCalledWith(state);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('submit()', () => {
|
||||
describe('when controller.form', () => {
|
||||
it(`should call controller.form.setSubminted if controller.form is defined`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.form = {$setSubmitted: () => {}};
|
||||
spyOn(controller.form, '$setSubmitted');
|
||||
controller.submit();
|
||||
|
||||
expect(controller.form.$setSubmitted).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it(`should call controller.invalidForm if controller.form.$valid is not defined`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.form = {$setSubmitted: () => {}};
|
||||
spyOn(controller, 'invalidForm');
|
||||
controller.submit();
|
||||
|
||||
expect(controller.invalidForm).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('when !controller.dataChanged()', () => {
|
||||
it(`should call controller.noChanges()`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
spyOn(controller, 'noChanges');
|
||||
controller.submit();
|
||||
|
||||
expect(controller.noChanges).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('when controller.save()', () => {
|
||||
it(`should set controller.save.model property`, () => {
|
||||
let controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
|
||||
controller.save = {};
|
||||
controller.data = {originalInfo: 'original data', info: 'new data'};
|
||||
controller.orgData = {originalInfo: 'original data'};
|
||||
controller.submit();
|
||||
|
||||
expect(controller.save.model).toEqual({info: 'new data'});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
import * as core from 'core';
|
||||
|
||||
export const client = () => {
|
||||
return new Promise(resolve => {
|
||||
require.ensure([], () => {
|
||||
require('client');
|
||||
resolve('client');
|
||||
}, 'client');
|
||||
});
|
||||
};
|
||||
|
||||
core.splitingRegister.register('client', client);
|
||||
|
||||
export const production = () => {
|
||||
return new Promise(resolve => {
|
||||
require.ensure([], () => {
|
||||
require('production');
|
||||
resolve('production');
|
||||
}, 'production');
|
||||
});
|
||||
};
|
||||
|
||||
core.splitingRegister.register('production', production);
|
||||
|
||||
export const route = () => {
|
||||
return new Promise(resolve => {
|
||||
require.ensure([], () => {
|
||||
require('route');
|
||||
resolve('route');
|
||||
}, 'route');
|
||||
});
|
||||
};
|
||||
|
||||
core.splitingRegister.register('route', route);
|
|
@ -42,8 +42,8 @@ gulp.task('services', function() {
|
|||
'auth',
|
||||
'salix',
|
||||
'client',
|
||||
'production'
|
||||
// 'route'
|
||||
'production',
|
||||
'route'
|
||||
];
|
||||
|
||||
for (var service of lbServices)
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
const Jasmine = require('jasmine');
|
||||
const jasmine = new Jasmine();
|
||||
|
||||
jasmine.loadConfig({
|
||||
spec_dir: '',
|
||||
spec_files: ['*[Ss]pec.js']
|
||||
});
|
||||
|
||||
jasmine.execute();
|
|
@ -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",
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
module.exports = function(server) {
|
||||
require('../../../service/boot/root.js')(server);
|
||||
};
|
|
@ -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.json({
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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": {}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -1,32 +1,6 @@
|
|||
'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.loopback();
|
||||
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();
|
||||
});
|
||||
vnLoopback.boot(app, __dirname);
|
||||
|
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"generator-loopback": {}
|
||||
}
|
|
@ -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, "" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
module.exports = function(server) {
|
||||
require('../../../service/boot/root.js')(server);
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"loopback-component-explorer": {
|
||||
"mountPath": "/explorer"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"final:after": {
|
||||
"strong-error-handler": {
|
||||
"params": {
|
||||
"debug": true,
|
||||
"log": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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": {}
|
||||
}
|
||||
}
|
|
@ -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});
|
||||
};
|
||||
|
||||
|
|
@ -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();
|
||||
};
|
||||
};
|
|
@ -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"
|
||||
|
|
|
@ -1,44 +1,5 @@
|
|||
'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();
|
||||
});
|
||||
var app = module.exports = vnLoopback.loopback();
|
||||
vnLoopback.boot(app, __dirname);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
*.sql
|
|
@ -1,7 +1,12 @@
|
|||
FROM mysql:5.6.37
|
||||
|
||||
MAINTAINER Vicente Falco
|
||||
|
||||
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
|
||||
|
||||
COPY localDB01Structure.sql /docker-entrypoint-initdb.d
|
||||
COPY localDB02Inserts.sql /docker-entrypoint-initdb.d
|
||||
|
||||
CMD ["mysqld"]
|
||||
|
||||
EXPOSE 3306
|
|
@ -0,0 +1,3 @@
|
|||
# Loopback wrapper by Verdnatura
|
||||
|
||||
This projects wraps the loopback library.
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
Self.defineScope({where: {isManaged: {neq: 0}}});
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = function(Account) {
|
||||
module.exports = function(Self) {
|
||||
// Validations
|
||||
|
||||
Account.validatesUniquenessOf('name', {
|
||||
Self.validatesUniquenessOf('name', {
|
||||
message: 'Ya existe un usuario con ese nombre'
|
||||
});
|
||||
};
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "Account",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"base": "VnModel",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "Country",
|
||||
"base": "VnModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "Province",
|
||||
"base": "VnModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "VnModel",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "vn-loopback",
|
||||
"version": "1.0.0",
|
||||
"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.14.0",
|
||||
"loopback-boot": "^2.26.2",
|
||||
"loopback-component-explorer": "^4.2.0",
|
||||
"loopback-connector-mysql": "^3.0.0",
|
||||
"loopback-connector-remote": "^3.1.1",
|
||||
"loopback-context": "^3.3.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": "Loopback wrapper by Verdnatura"
|
||||
}
|
|
@ -8,18 +8,18 @@ module.exports = function(app) {
|
|||
if (!acls)
|
||||
model.settings.acls = acls = [];
|
||||
|
||||
acls.unshift({
|
||||
accessType: '*',
|
||||
principalType: 'ROLE',
|
||||
principalId: 'root',
|
||||
permission: 'ALLOW'
|
||||
});
|
||||
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;
|
||||
|
@ -30,8 +30,6 @@ module.exports = function(app) {
|
|||
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() {
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function(server) {
|
||||
module.exports = function(app) {
|
||||
function toJson(object) {
|
||||
let json = {};
|
||||
|
||||
|
@ -21,9 +21,9 @@ module.exports = function(server) {
|
|||
return json;
|
||||
}
|
||||
|
||||
server.get('/validations', function(req, res) {
|
||||
app.get('/validations', function(req, res) {
|
||||
let json = {};
|
||||
let models = server.models;
|
||||
let models = app.models;
|
||||
|
||||
for (let modelName in models) {
|
||||
let model = models[modelName];
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"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
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db": {
|
||||
"name": "db",
|
||||
"connector": "memory",
|
||||
"file": "db.json"
|
||||
},
|
||||
"client": {
|
||||
"name": "client",
|
||||
"connector": "remote",
|
||||
"url": "http://localhost:3002/api"
|
||||
}
|
||||
}
|
|
@ -34,3 +34,4 @@
|
|||
"url": "http://localhost:3002/api"
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
"compression": {},
|
||||
"cors": {
|
||||
"params": {
|
||||
"origin": true,
|
||||
"origin": "*",
|
||||
"credentials": true,
|
||||
"maxAge": 86400
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
|||
"helmet#frameguard": {
|
||||
"params": [
|
||||
"deny"
|
||||
]
|
||||
]
|
||||
},
|
||||
"helmet#hsts": {
|
||||
"params": {
|
||||
|
@ -37,12 +37,14 @@
|
|||
},
|
||||
"session": {},
|
||||
"auth": {
|
||||
"loopback#token": {}
|
||||
"loopback#token": {}
|
||||
},
|
||||
"auth:after": {
|
||||
"./middleware/currentUser": {}
|
||||
},
|
||||
"parse": {},
|
||||
"parse": {
|
||||
"body-parser#json":{}
|
||||
},
|
||||
"routes": {
|
||||
"loopback#rest": {
|
||||
"paths": [
|
|
@ -0,0 +1,13 @@
|
|||
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});
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
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();
|
||||
};
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function() {
|
||||
console.log('Date time middleware triggered.');
|
||||
res.json({datetime: new Date()});
|
||||
};
|
||||
};
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"_meta": {
|
||||
"sources": [
|
||||
"loopback/common/models",
|
||||
"loopback/server/models",
|
||||
"../common/models",
|
||||
"./models"
|
||||
],
|
||||
"mixins": [
|
||||
"loopback/common/mixins",
|
||||
"loopback/server/mixins",
|
||||
"../common/mixins",
|
||||
"./mixins"
|
||||
]
|
||||
},
|
||||
"user": {
|
||||
"dataSource": "auth"
|
||||
},
|
||||
"AccessToken": {
|
||||
"dataSource": "auth",
|
||||
"relations": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "user",
|
||||
"foreignKey": "userId"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ACL": {
|
||||
"dataSource": "auth"
|
||||
},
|
||||
"RoleMapping": {
|
||||
"dataSource": "auth"
|
||||
},
|
||||
"Role": {
|
||||
"dataSource": "auth"
|
||||
},
|
||||
"Account": {
|
||||
"dataSource": "auth"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
var loopback = require('loopback');
|
||||
var boot = require('loopback-boot');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var i18n = require('i18n');
|
||||
|
||||
module.exports = {
|
||||
loopback: loopback,
|
||||
boot: vnBoot
|
||||
};
|
||||
|
||||
function vnBoot(app, rootDir, cb) {
|
||||
// Internationalization
|
||||
|
||||
let i18nDir = rootDir + '/i18n';
|
||||
|
||||
if (fs.existsSync(i18nDir)) {
|
||||
i18n.configure({
|
||||
directory: i18nDir,
|
||||
defaultLocale: 'es'
|
||||
});
|
||||
|
||||
app.get('/prueba', function(req, res) {
|
||||
i18n.setLocale(req.get('Accept-Language').substring(0,2));
|
||||
res.send(i18n.__('Hello'));
|
||||
});
|
||||
}
|
||||
|
||||
// View
|
||||
|
||||
let viewDir = path.join(rootDir, '../client');
|
||||
|
||||
if (fs.existsSync(viewDir)) {
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', viewDir);
|
||||
app.use(loopback.static(path.resolve(rootDir, '../client')));
|
||||
}
|
||||
|
||||
// Initialization
|
||||
|
||||
let packageJson = require(rootDir + '/../package.json');
|
||||
let appName = packageJson.name;
|
||||
|
||||
app.start = function() {
|
||||
return app.listen(function() {
|
||||
app.emit('started');
|
||||
var baseUrl = app.get('url').replace(/\/$/, '');
|
||||
console.log(`Web server ${appName} listening at: %s`, baseUrl);
|
||||
});
|
||||
};
|
||||
|
||||
let config = require('./config.json');
|
||||
|
||||
for (var key in config) {
|
||||
app.set(key, config[key]);
|
||||
}
|
||||
|
||||
var bootOptions = {
|
||||
appRootDir: __dirname,
|
||||
appConfigRootDir: rootDir,
|
||||
modelsRootDir: rootDir,
|
||||
modelSources: [
|
||||
"loopback/common/models",
|
||||
"loopback/server/models",
|
||||
__dirname + "/../common/models",
|
||||
__dirname + "/models",
|
||||
rootDir + "/../common/models",
|
||||
rootDir + "/models"
|
||||
],
|
||||
mixinDirs: [
|
||||
"loopback/common/mixins",
|
||||
"loopback/server/mixins",
|
||||
__dirname + "/../common/mixins",
|
||||
__dirname + "/mixins",
|
||||
rootDir + "/../common/mixins",
|
||||
rootDir + "/mixins"
|
||||
],
|
||||
bootDirs: [
|
||||
__dirname + "/boot",
|
||||
rootDir + "/boot"
|
||||
]
|
||||
};
|
||||
|
||||
boot(app, bootOptions, function(err) {
|
||||
if (err) throw err;
|
||||
if (require.main === module)
|
||||
app.start();
|
||||
|
||||
if (cb)
|
||||
cb(app);
|
||||
});
|
||||
}
|
|
@ -30,10 +30,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;
|
||||
|
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
/client/
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"extends": "loopback"
|
||||
}
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"generator-loopback": {}
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
module.exports = function(server) {
|
||||
require('../../../service/boot/root.js')(server);
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"loopback-component-explorer": {
|
||||
"mountPath": "/explorer"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"final:after": {
|
||||
"strong-error-handler": {
|
||||
"params": {
|
||||
"debug": true,
|
||||
"log": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
};
|
||||
};
|
|
@ -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"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
'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();
|
||||
});
|
||||
var app = module.exports = vnLoopback.loopback();
|
||||
vnLoopback.boot(app, __dirname);
|
||||
|
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"generator-loopback": {}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
module.exports = function(server) {
|
||||
require('../../../service/boot/root.js')(server);
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"loopback-component-explorer": {
|
||||
"mountPath": "/explorer"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"final:after": {
|
||||
"strong-error-handler": {
|
||||
"params": {
|
||||
"debug": true,
|
||||
"log": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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": {}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
};
|
||||
};
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
'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();
|
||||
});
|
||||
var app = module.exports = vnLoopback.loopback();
|
||||
vnLoopback.boot(app, __dirname);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue