Commit b85f1fdf authored by D’jalmar Gutierrez Titirico's avatar D’jalmar Gutierrez Titirico 🚲

se excluyeron las entidades del servidor

parent 567c81c8
......@@ -37,12 +37,12 @@ module.exports = function (grunt) {
},
express: {
options: {
port: process.env.PORT || 9000
port: process.env.PORT || 9001
},
dev: {
options: {
script: '<%= yeoman.server %>',
debug: true
debug: 5859
}
},
prod: {
......@@ -102,14 +102,14 @@ module.exports = function (grunt) {
'<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: true
livereload: 35728,
}
},
express: {
files: ['<%= yeoman.server %>/**/*.{js,json}'],
tasks: ['express:dev', 'wait'],
options: {
livereload: true,
livereload: 35728,
spawn: false //Without this option specified express won't be reloaded
}
},
......@@ -193,7 +193,8 @@ module.exports = function (grunt) {
'node-inspector': {
custom: {
options: {
'web-host': 'localhost'
'web-host': 'localhost',
'debug-port': 5859
}
}
},
......@@ -205,7 +206,7 @@ module.exports = function (grunt) {
options: {
nodeArgs: ['--debug-brk'],
env: {
PORT: process.env.PORT || 9000
PORT: process.env.PORT || 9001
},
callback: function (nodemon) {
nodemon.on('log', function (event) {
......@@ -215,7 +216,7 @@ module.exports = function (grunt) {
// opens browser on initial server start
nodemon.on('config:update', function () {
setTimeout(function () {
require('open')('http://localhost:8080/debug?port=5858');
require('open')('http://localhost:8080/debug?port=5859');
}, 500);
});
}
......@@ -602,11 +603,11 @@ module.exports = function (grunt) {
},
files: {
'<%= yeoman.client %>/index.html': [
[
'<%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js',
'!{.tmp,<%= yeoman.client %>}/app/app.{js,ts}'
]
[
'<%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js',
'!{.tmp,<%= yeoman.client %>}/app/app.{js,ts}'
]
]
}
},
......@@ -668,22 +669,22 @@ module.exports = function (grunt) {
});
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
}
if (target === 'debug') {
return grunt.task.run([
'clean:server',
'env:all',
'concurrent:pre',
'concurrent:server',
'injector',
'wiredep:client',
'postcss',
'concurrent:debug'
]);
}
// if (target === 'dist') {
// return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
// }
//
// if (target === 'debug') {
// return grunt.task.run([
// 'clean:server',
// 'env:all',
// 'concurrent:pre',
// 'concurrent:server',
// 'injector',
// 'wiredep:client',
// 'postcss',
// 'concurrent:debug'
// ]);
// }
grunt.task.run([
'clean:server',
......@@ -706,95 +707,95 @@ module.exports = function (grunt) {
});
grunt.registerTask('test', function(target, option) {
if (target === 'server') {
return grunt.task.run([
'env:all',
'env:test',
'mochaTest:unit',
'mochaTest:integration'
]);
}
else if (target === 'client') {
return grunt.task.run([
'clean:server',
'env:all',
'concurrent:pre',
'concurrent:test',
'injector',
'postcss',
'wiredep:test',
'karma'
]);
}
else if (target === 'e2e') {
if (option === 'prod') {
return grunt.task.run([
'build',
'env:all',
'env:prod',
'express:prod',
'protractor'
]);
}
else {
return grunt.task.run([
'clean:server',
'env:all',
'env:test',
'concurrent:pre',
'concurrent:test',
'injector',
'wiredep:client',
'postcss',
'express:dev',
'protractor'
]);
}
}
else if (target === 'coverage') {
if (option === 'unit') {
return grunt.task.run([
'env:all',
'env:test',
'mocha_istanbul:unit'
]);
}
else if (option === 'integration') {
return grunt.task.run([
'env:all',
'env:test',
'mocha_istanbul:integration'
]);
}
else if (option === 'check') {
return grunt.task.run([
'istanbul_check_coverage'
]);
}
else {
return grunt.task.run([
'env:all',
'env:test',
'mocha_istanbul',
'istanbul_check_coverage'
]);
}
}
else grunt.task.run([
'test:server',
'test:client'
// if (target === 'server') {
// return grunt.task.run([
// 'env:all',
// 'env:test',
// 'mochaTest:unit',
// 'mochaTest:integration'
// ]);
// }
//
// else if (target === 'client') {
return grunt.task.run([
'clean:server',
'env:all',
'concurrent:pre',
'concurrent:test',
'injector',
'postcss',
'wiredep:test',
'karma'
]);
//}
//
// else if (target === 'e2e') {
//
// if (option === 'prod') {
// return grunt.task.run([
// 'build',
// 'env:all',
// 'env:prod',
// 'express:prod',
// 'protractor'
// ]);
// }
//
// else {
// return grunt.task.run([
// 'clean:server',
// 'env:all',
// 'env:test',
// 'concurrent:pre',
// 'concurrent:test',
// 'injector',
// 'wiredep:client',
// 'postcss',
// 'express:dev',
// 'protractor'
// ]);
// }
// }
//
// else if (target === 'coverage') {
//
// if (option === 'unit') {
// return grunt.task.run([
// 'env:all',
// 'env:test',
// 'mocha_istanbul:unit'
// ]);
// }
//
// else if (option === 'integration') {
// return grunt.task.run([
// 'env:all',
// 'env:test',
// 'mocha_istanbul:integration'
// ]);
// }
//
// else if (option === 'check') {
// return grunt.task.run([
// 'istanbul_check_coverage'
// ]);
// }
//
// else {
// return grunt.task.run([
// 'env:all',
// 'env:test',
// 'mocha_istanbul',
// 'istanbul_check_coverage'
// ]);
// }
//
// }
//
// else grunt.task.run([
// 'test:server',
// 'test:client'
// ]);
});
grunt.registerTask('build', [
......
......@@ -3,7 +3,7 @@
angular.module('moduloPersonalApp.constants', [])
.constant('appConfig', {userRoles:['guest','user','ADMINISTRATOR']})
.constant('appConfig', {userRoles:['guest','user','ADMINISTRATOR'],serverAddress:'http://localhost:9000',clientAddress:'http:localhost:9000'})
;
})(angular);
\ No newline at end of file
......@@ -2,8 +2,8 @@
'use strict';
class CargoService {
constructor($resource) {
this.resource = $resource('/api/cargos/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/cargos/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
})
......
......@@ -2,8 +2,8 @@
'use strict';
class ComentarioService {
constructor($resource) {
this.resource = $resource('/api/comentarios/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress +'/api/comentarios/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
})
......
......@@ -2,8 +2,8 @@
'use strict';
class DatoPostulanteService {
constructor($resource) {
this.resource = $resource('/api/datosPostulantes/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/datosPostulantes/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
})
......
(()=> {
'use strict';
class PostulacionService {
constructor($resource) {
this.resource = $resource('/api/postulaciones/:id', {id: '@_id', postulanteId: '@_id', cargoId: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/postulaciones/:id', {
id: '@_id',
postulanteId: '@_id',
cargoId: '@_id'
}, {
update: {method: 'PUT'},
query: {isArray: false},
postulacionesPostulante: {
......
......@@ -2,8 +2,8 @@
'use strict';
class PostulanteService {
constructor($resource) {
this.resource = $resource('/api/postulantes/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/postulantes/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
});
......
......@@ -2,8 +2,8 @@
'use strict';
class TagService {
constructor($resource) {
this.resource = $resource('/api/tags/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/tags/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
});
......
......@@ -2,8 +2,8 @@
'use strict';
class TagPostulanteService {
constructor($resource) {
this.resource = $resource('/api/tagsPostulantes/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/tagsPostulantes/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
})
......
......@@ -2,8 +2,8 @@
'use strict';
class TipoDatoService {
constructor($resource) {
this.resource = $resource('/api/tiposDato/:id', {id: '@_id'}, {
constructor($resource, appConfig) {
this.resource = $resource(appConfig.serverAddress + '/api/tiposDato/:id', {id: '@_id'}, {
update: {method: 'PUT'},
query: {isArray: false}
});
......
'use strict';
(function() {
(function () {
function UsuarioService($resource) {
return $resource('/api/usuarios/:id/:controller', {
function UsuarioService($resource, appConfig) {
return $resource(appConfig.serverAddress + '/api/usuarios/:id/:controller', {
id: '@_id'
}, {
get: {
......
......@@ -10,7 +10,7 @@
}
var Autenticacion = {
iniciarSesion: function iniciarSesion({nombreUsuario, contraseña}, callback) {
return $http.post('/api/autenticar/ldap', {
return $http.post(appConfig.serverAddress + '/api/autenticar/ldap', {
nombreUsuario: nombreUsuario,
contrasena: contraseña
})
......
......@@ -8,7 +8,7 @@
// añadir token en las cabeceras
request(config) {
config.headers = config.headers || {};
if ($cookies.get('token') && Util.isSameOrigin(config.url)) {
if ($cookies.get('token') ) {
config.headers.Authorization = 'Bearer ' + $cookies.get('token');
}
return config;
......
/**
* This file uses the Page Object pattern to define the main page for tests
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
*/
'use strict';
var NavbarComponent = function() {
this.navbar = element(by.css('.navbar'));
this.navbarHeader = this.navbar.element(by.css('.navbar-header'));
this.navbarNav = this.navbar.element(by.css('#navbar-main .nav.navbar-nav:not(.navbar-right)'));
};
module.exports = new NavbarComponent();
/**
* This file uses the Page Object pattern to define the main page for tests
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
*/
'use strict';
var MainPage = function() {
this.heroEl = element(by.css('.hero-unit'));
this.h1El = this.heroEl.element(by.css('h1'));
this.imgEl = this.heroEl.element(by.css('img'));
};
module.exports = new MainPage();
'use strict';
var config = browser.params;
describe('Main View', function() {
var page;
beforeEach(function() {
let promise = browser.get(config.baseUrl + '/');
page = require('./main.po');
return promise;
});
it('should include jumbotron with correct data', function() {
expect(page.h1El.getText()).to.eventually.equal('\'Allo, \'Allo!');
expect(page.imgEl.getAttribute('src')).to.eventually.match(/yeoman.png$/);
expect(page.imgEl.getAttribute('alt')).to.eventually.equal('I\'m Yeoman');
});
});
{
"name": "modulo-personal",
"name": "modulo-personal-cliente",
"version": "0.2.2",
"main": "server/app.js",
"dependencies": {
"babel-runtime": "^5.8.20",
"body-parser": "^1.13.3",
......@@ -9,27 +8,12 @@
"compression": "^1.5.2",
"cookie-parser": "^1.3.5",
"ejs": "^2.3.3",
"errorhandler": "^1.4.2",
"express": "^4.13.3",
"express-jwt": "^3.0.0",
"express-sequelize-session": "0.4.0",
"express-session": "^1.11.3",
"jsonwebtoken": "^5.0.0",
"lodash": "^3.10.1",
"lusca": "^1.3.0",
"method-override": "^2.3.5",
"morgan": "~1.6.1",
"mysql": "^2.10.2",
"node-validator": "^0.1.22",
"passport": "~0.3.0",
"passport-ldapauth": "^0.5.0",
"passport-local": "^1.0.0",
"pg": "^4.5.1",
"pg-hstore": "^2.3.2",
"sequelize": "^3.5.1",
"serve-favicon": "^2.3.0",
"sqlite3": "~3.1.1",
"validator": "^4.9.0"
"errorhandler": "^1.4.2",
"express": "^4.13.3"
},
"devDependencies": {
"autoprefixer": "^6.0.0",
......
/**
* Using Rails-like standard naming convention for endpoints.
* GET /api/cargos -> index
* POST /api/cargos -> create
* GET /api/cargos/:id -> show
* PUT /api/cargos/:id -> update
* DELETE /api/cargos/:id -> destroy
*/
'use strict';
import _ from 'lodash';
import {Cargo} from '../../sqldb';
import * as errorMan from '../../components/errors/errorManager'
// Gets a list of Cargos
export function index(req, res) {
Cargo.findAndCountAll(req.parametros)
.then(errorMan.respondWithResult(res))
.catch(errorMan.handleError(res));
}
// Gets a single Cargo from the DB
export function show(req, res) {
req.parametros.where = {
_id: req.params.id
};
Cargo.find(req.parametros)
.then(errorMan.handleEntityNotFound(res))
.then(errorMan.respondWithResult(res))
.catch(errorMan.handleError(res));
}
// Creates a new Cargo in the DB
export function create(req, res) {
Cargo.create(req.body)
.then(errorMan.respondWithResult(res, 201))
.catch(errorMan.handleError(res));
}
// Updates an existing Cargo in the DB
export function update(req, res) {
if (req.body._id) {
delete req.body._id;
}
Cargo.find({
where: {
_id: req.params.id
}
})
.then(errorMan.handleEntityNotFound(res))
.then(errorMan.saveUpdates(req.body))
.then(errorMan.respondWithResult(res))
.catch(errorMan.handleError(res));
}
// Deletes a Cargo from the DB
export function destroy(req, res) {
Cargo.find({
where: {
_id: req.params.id
}
})
.then(errorMan.handleEntityNotFound(res))
.then(errorMan.removeEntity(res))
.catch(errorMan.handleError(res));
}
/**
* Cargo model events
*/
'use strict';
import {EventEmitter} from 'events';
var Cargo = require('../../sqldb').Cargo;
var CargoEvents = new EventEmitter();
// Set max event listeners (0 == unlimited)
CargoEvents.setMaxListeners(0);
// Model events
var events = {
'afterCreate': 'save',
'afterUpdate': 'save',
'afterDestroy': 'remove'
};
// Register the event emitter to the model events
for (var e in events) {
var event = events[e];
Cargo.hook(e, emitEvent(event));
}
function emitEvent(event) {
return function(doc, options, done) {
CargoEvents.emit(event + ':' + doc._id, doc);
CargoEvents.emit(event, doc);
done(null);
}
}
export default CargoEvents;
'use strict';
var app = require('../..');
import {Cargo} from '../../sqldb';
import request from 'supertest';
describe('Cargo API:', function() {
var token;
var nuevoCargo = {};
before(function (done) {
Cargo.destroy({where: {}}).then(()=> {
request(app)
.post('/api/autenticar/ldap')
.send({
nombreUsuario: 'test',
contrasena: '123456'
})
.expect(200)
.expect('Content-Type', /json/)
.end((err, res)=> {
token = res.body.token;
done();
})
});
});
describe('GET /api/cargos', function () {
it('Debe responder con un objeto que contiene la cantidad de cargos y un array de todos los cargos', function (done) {
request(app)
.get('/api/cargos')
.set('authorization', 'Bearer ' + token)
.expect(200)
.expect('Content-Type', /json/)
.end((err, res)=> {
expect(res.body.rows).to.be.instanceOf(Array);
expect(res.body.count).to.equal(0);
done();
})
});
});
describe('POST /api/cargos', function () {
it('Debe responder con el cargo creado', function (done) {