new micro-service route: need reinstall all dependencies

This commit is contained in:
dherrero 2017-10-05 14:26:04 +02:00
parent 4d487e7980
commit 431032177c
23 changed files with 396 additions and 1 deletions

View File

@ -42,7 +42,8 @@ gulp.task('services', function() {
'auth',
'salix',
'client',
'production'
'production',
'route'
];
for (var service of lbServices)

View File

@ -40,6 +40,9 @@ http {
location ~ ^/production(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3004/$1$is_args$args;
}
location ~ ^/route(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3005/$1$is_args$args;
}
# Este tiene que ser el último
location ~ ^(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3001/$1$is_args$args;

View File

@ -35,6 +35,9 @@ http {
location ~ ^/production(?:/(.*))?$ {
proxy_pass http://production:3004/$1$is_args$args;
}
location ~ ^/route(?:/(.*))?$ {
proxy_pass http://route:3005/$1$is_args$args;
}
# Este tiene que ser el último
location ~ ^(?:/(.*))?$ {
proxy_pass http://salix:3001/$1$is_args$args;

View File

@ -0,0 +1,13 @@
# 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

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

3
services/route/.eslintrc Normal file
View File

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

19
services/route/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
*.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

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

13
services/route/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM node:6.9.1
COPY . /app
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "."]
EXPOSE 3005

3
services/route/README.md Normal file
View File

@ -0,0 +1,3 @@
# My Application
The project is generated by [LoopBack](http://loopback.io).

View File

@ -0,0 +1,29 @@
{
"name": "Route",
"base": "MyModel",
"validateUpsert": true,
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"date": {
"type": "date"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}
]
}

View File

@ -0,0 +1,33 @@
{
"name": "vn-route",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
"lint": "eslint .",
"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"
}

View File

@ -0,0 +1,6 @@
'use strict';
module.exports = function enableAuthentication(server) {
// enable authentication
server.enableAuth();
};

View File

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

View File

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

View File

@ -0,0 +1,22 @@
{
"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
}
}

View File

@ -0,0 +1,36 @@
{
"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

@ -0,0 +1,36 @@
{
"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

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

View File

@ -0,0 +1,60 @@
{
"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

@ -0,0 +1,13 @@
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

@ -0,0 +1,50 @@
{
"_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"
},
"AccessToken": {
"dataSource": "auth",
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "userId"
}
}
},
"ACL": {
"dataSource": "auth",
"public": false
},
"RoleMapping": {
"dataSource": "auth",
"public": false
},
"Role": {
"dataSource": "auth",
"public": false
},
"Account": {
"dataSource": "auth"
},
"Route": {
"dataSource": "vn",
"public": true
}
}

View File

@ -0,0 +1,29 @@
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
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();
});