Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • #974-receita-potencial
  • aggregate_enrollment
  • attendance_rate
  • courseAggregate
  • db-conn
  • development
  • docentes-ies-ente-federativo
  • enrollment_rate
  • es23-docentes-por-ente-federativo
  • es23-superior-enrollment
  • homologa
  • hotfix-enrollment-aggregate
  • instruction_level_fix2
  • instruction_level_fixes
  • instruction_number
  • issue_935
  • issue_953
  • issue_958
  • issues_indicadores_agregados
  • master
  • msh22-development-patch-10494
  • new-indicators
  • nova-correcao-funcionarios-2024
  • receita-potencial
  • revert-222fa403
  • teachers-ies
  • years-of-study-mean
  • v0.1.0
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.1.0
  • v1.1.1
  • v1.14
  • v1.14.0
  • v1.14.1
  • v1.14.2
  • v1.15.1
  • v1.16.0
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.3.3
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.5.0
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.8.0
  • v1.8.1
  • v1.8.2
  • v1.8.3
  • v1.9.0
60 results

Target

Select target project
  • simcaq/simcaq-node
  • SMPPIR/SMPPIR-Node
2 results
Select Git revision
  • Add_region_in_institution
  • Remove_MongoDB
  • adding-age-to-taxa-homicidios
  • comparador
  • demanda4
  • development
  • documentation
  • fix_eixos
  • indigenas_territorial
  • indigenas_territorial_route
  • institution
  • jvt_viva_trabalho
  • master
  • metrics_fix
  • pessoa_to_familia
  • quilombola_shools
  • quotas_acessibility
  • rotas_indigenas
  • social_support
  • traditional_families
  • updating_routes
  • v0.1.0
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.1.0
  • v1.1.1
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
32 results
Show changes

Commits on Source 2658

2,558 additional commits have been omitted to prevent performance issues.
{ 'presets': ['es2015'] }
[
"**/test/*.js"
]
{
"extends": "airbnb",
"root": true,
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
"jsx-a11y/heading-has-content": [ "off" ],
"jsx-a11y/anchor-has-content": [ "off" ],
"indent": [ "error", 4 ],
"no-unused-vars": [ "error", { "args": "none" }],
"no-param-reassign": [ "off" ]
}
}
.vscode
.DS_Store
.idea
lib-cov
......@@ -10,8 +11,26 @@ lib-cov
*.gz
pids
logs
results
npm-debug.log
node_modules/
build/*
.gulp-cache
config.json
docs/
.vscode/
package-lock.json
Dockerfile
DockerfileAntigo
src/libs/db/postgres.js
docker-compose.yml
entrypoint.sh
gulpfile*
gulpfile.template.js
gulpfile.babel.js
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.15.7 - 2020-11-11
#Changes
- Fix Universitys in first step in course and enrollment indicators
- Fix Clear filters
## 1.15.6 - 2020-10-06
## Fix
- Change json subroute in university enrollment
## 1.15.5 - 2020-10-02
## Fix
- Employees indicator with school filter
## 1.15.4 - 2020-09-30
## Changed
- Remove next in univsersity enrollment
## 1.15.3 - 2020-09-30
## Changed
- Change result finish university
## 1.15.2 - 2020-09-21
## Changed
- Add localoffer in dims location in university enrollment
## 1.15.1 - 2020-07-31
## Changed
- Classroom_count final result is now rounded to 2 decimals intead of using ceil
## 1.15.0 - 2020-07-16
## Added
- Route location
## Changed
- Dim income_level in route pibpercapita now uses a different table, pib_quintis
- Population now uses ibge_pib table
## 1.14.2 - 2020-07-14
## Changed
- Courses route
- Addmissing
## 1.14.1 - 2020-06-24
- Fix gross and liquid enrollment ratio indicators
## 1.14.0 - 2020-06-17
## Added
- Route school_location
- Route mesoregion
- Route microregion
## Changed
- City route now returns microregion_id and mesoregion_id
- Update classCount base filters
- Update classroom base query
- Update classroomCount base filters in school
- Removed addMissing from cub route
- Changed dailyChargeAmount filter pattern
- Enrollment now has mesoregion/microregion dims/filters
- Changed reqFilters in outOfSchool route
- School now has mesoregion/microregion dims/filters
- Teacher now has mesoregion/microregion dims/filters
- UnivesityEnrollment now has mesoregion/microregion dims/filters
## 1.13.4 - 2020-06-05
- Arrangment filter in school indicator 2007-2019
- Employees Indicator 2007-2019
## 1.13.3 - 2020-05-21
## 1.13.2 - 2020-05-21
## Changed
- Rename rural category
## 1.13.1 - 2020-05-12
## Changed
- Fix dot error
## 1.13.0 - 2020-04-XX
## Added
- Added 2019 data
- Added Goverment agreement in school
- Added Arrangment dims in school
## Changed
- Updated 2007-2018
- Updated education level mod
- Updated adm_dependency_detailed filter
- Updated rural_location filter
- Updated period labels
- AddMissing will now force ordination by id
- Updated all routes to contain id in region, state and city dims
## 1.12.6 - 2020-02-02
## Changed
- Fix teacher education mod dimension
- Fix text
## 1.12.5 - 2020-01-27
## Changed
- Fix duplicated cities in courseCount
## 1.12.4 - 2020-01-27
## Changed
- Fix addMissing
## 1.12.3 - 2019-12-20
## Changed
- Fix new categories in education type for teacher
## 1.12.2 - 2019-12-19
## Changed
- Fix addMissing
- Add new categories in education type for teacher
## 1.12.1 - 2019-12-12
## Changed
- Added categories to adm dependency
## 1.12.0 - 2019-11-25
## Changed
- Add teacher count to classroom_count route
## 1.11.17 - 2019-10-08
## Changed
- Fix query\_exec
## 1.11.16 - 2019-10-30
## Changed
- University Teacher updated
## 1.11.15 - 2019-10-16
## Changed
- Fix addMissing for classCount route
## 1.11.14 - 2019-10-13
## Changed
- OCDE updated
## 1.11.13 - 2019-09-11
## Changed
- Classroom with dim location and city filter, will always return both locations
## 1.11.12 - 2019-09-10
## Changed
- Changed classroom filters to match classroomCount
## 1.11.11 - 2019-09-09
## Changed
- Changed classroomCount filters
## 1.11.10 - 2019-08-23
## Changed
- Removed year limitation
- Updated existing variables
## 1.11.9 - 2019-07-25
## Changed
- Course count order fix
- Course count missing fix
## 1.11.8 = 2019-07-19
## Changed
- Remove /user route
## 1.11.7 - 2019-07-12
## Changed
- EnrollmentProjection now returns empty values with 0
## 1.11.6 - 2019-07-11
## Changed
- Return haveSportsCourtCoverage and haveCourtyardCoverage = [] in route school_infrastructure
## 1.11.5 - 2019-07-09
## Changed
- Fix integral time
- Fix match queries in school_infrastructure
## 1.11.4 - 2019-06-17
## Changed
- Changed enrollment variable
- Added location and latitude to state and city
- Changed courseCount variables
- Removed 'Not classified' from teacher
## 1.11.3 - 2019-06-17
## Changed
- Changed variables from university
- Removed year limitation from university
## 1.11.2 - 2019-06-17
## Changed
- transport now uses an aggregate table
## 1.11.1 - 2019-06-10
## Changed
- ClassroomCount now uses an aggregate table
## 1.11.0 - 2019-05-24
## Changed
- Add university teacher indicator for 2017
## 1.10.5 - 2019-05-23
## Changed
- Revert api.js
## 1.10.4 - 2019-05-23
## Changed
- Fix order in enrollment indicator
## Added
- Added university enrollment indicator
- Added course count indicator
## 1.10.3 - 2019-05-22
## Changed
- Fix schoolInfrastructure.js
## 1.10.2 - 2019-05-10
## Changed
- Fix api.js
## 1.10.0 - 2019-05-10
## Added
- Added university indicator
## 1.9.8 - 2019-08-02
## Changed
- Fix bug duplicate city name in classroom count
## 1.9.7 - 2019-05-02
## Changed
- Fix enrollment projection
- Fix enrollment number in classroom count
- Fix error in class count
## 1.9.6 - 2019-04-02
## Changed
- Fix null in integral time
## 1.9.5 - 2019-03-15
## Changed
- Fix join's in class count route
## 1.9.4 - 2019-03-12
## Changed
- Change docente.id to docente.id_docente
## 1.9.3 - 2019-03-12
## Changed
- Fix addMissing function
## 1.9.2 - 2019-02-20
## Changed
- Fix location variable in table
## 1.9.1 - 2019-02-14
## Changed
- Fix join's in financial route
## 1.9.0 - 2018-11-24
## Changed
- Fix school infrastructure results when partial or needed schools query return empty
- Block 2 or more dimensions in daily_charge_amount/average
## 1.8.3 - 2018-11-24
### Changed
- Fixed reulst return in classroom count
## 1.8.2 - 2018-11-23
### Changed
- Fixed class count route
- Fixed classroom count school year bug
## 1.8.1 - 2018-11-13
### Changed
- Fixed bug in id2str with inexistent convert function
## 1.8.0 - 2018-11-13
### Added
- Add financial route
- Add employees route
### Changed
- Fix school route
- Fix transport route
- Fix return where integral time is null
- Classroom count route returns school year results for education level 1
## 1.7.0 - 2018-09-20
### Changed
- Fix return string in contract type id 1
- Fix out of school route
- Fix pib-per-capita route
- Fix filters in infrastructure route
- Remove filters in transport route
## 1.6.1 - 2018-08-23
### Changed
- Fix return json name in transport route
## 1.6.0 - 2018-08-17
### Added
- Dimension state in route `enrollment` now returns state name and id
- `school` route now has a `search` parameter. You can search by city name or state abbreviation
- Added all age range convertion
- Added special class and all age range to id2str
- Added `school infratructure` route
- Added `INEP` route for Portal MEC
### Changed
- Fix `auxiliar` indicator
- Add property "don't group" in RQF to dismiss the group by and order by clause
- Change RQF filters in `auxiliar` route
- Fix total classrooms needed bug in classroom count
- Add special class and all age range to enrollment route
## 1.5.0 - 2018-07-30
### Added
- Add portaMec route
- Fix bug in diagnosis and projection routes
## 1.4.2 - 2018-07-23
### Added
- Added new url's in daily charge amount indicator
### Changed
- Fix variable name and url in daily charge amount indicator
## 1.4.1 - 2018-07-03
### Changed
- Fix duplicate in transport indicator
## 1.4.0 - 2018-06-27
### Added
- Add school building filter/dimension to school count route
- Add transport indicator
- Add cub route
### Changed
- Fixed CSV output when result objects have nested arrays and/or objects
- Limit year range to 2007-2015 in out of school indicator
- Fix auxiliar indicator
## 1.3.3 - 2018-06-27
### Changed
- Removed restriction of year > 2014 of school count route
## 1.3.2 - 2018-06-20
### Changed
- Fixed math error in classroom count at total classroom needed expression
## 1.3.1 - 2018-06-19
### Changed
- Fixed bug with Federal District and missing cities in classroom count
## 1.3.0 - 2018-06-18
### Added
- Daily charge amount route
## 1.2.3 - 2018-06-14
### Changed
- Fixed roundig error in classroom count route
- Route performance improved
## 1.2.2 - 2018-05-22
### Changed
- Fixed bug with missing education levels in classroom count
## 1.2.1 - 2018-05-22
### Changed
- Add state id in infrastructure
## 1.2.0 - 2018-05-21
### Added
- Classroom count route
## 1.1.1 - 2018-05-10
### Changed
- Fix bug in gloss enrollment ratio route
- Fix bug in liquid enrollment ratio route
## 1.1.0 - 2018-05-02
### Added
- Out of school population indicator
- Liquid enrollment ratio indicator
- Gloss enrollment ratio indicator
## 1.0.3 - 2018-04-27
### Changed
- Fixed bug undefined field in some indicators
## 1.0.2 - 2018-04-18
### Changed
- Fixed bug in pibpercapita route
## 1.0.1 - 2018-03-15
### Changed
- Fix missing school id in teacher and class routes
## 1.0.0 - 2018-03-14
### Added
- `ReqQueryFields` middleware added to substitute parseParams and do SQL building automagically with the URL params
- Upgrade to database v2
- Added user model
- Passport.js added for user authentication
- Added routes to create and authenticate a user
- Added simulation model
- Added routes to save and retrieve simulations in `/simulation`
- Add middleware to convert ids to names
### Changed
- Query middleware throws a 404 when the result is empty
- Change filters and dimensions names! No more `_id`. **Breaks compability**
- config.json.example now has values for development, test and production environments
- Min Node version is 6.8.1
- Cache is now defined per route
- Errors from MonetDB are now returned by the query_exec and query middlewares
- Tests are now in different files
### Removed
- Parse Params middleware removed
## 0.1.0 - 2016-10-10
### Added
**Database**
- MonetDB connection middleware
- MongoDB connection middleware
- query_exec custom middleware (promise that executes an SQL query with optional parameters)
- This version depends on the version 0.1.0 of [MonetDB schema](https://gitlab.c3sl.ufpr.br/simcaq/monetdb)
**Enrollments**
- Enrollments route with all sub dependencies
**Middlewares**
- parseParams middleware to parse HTTP GET params
- query middleware that serves as an interface between squel generated sql and the query execution
- response middleware that gives a standard response (json, csv or xml)
# Contributor code of conduct
As contributors and maintainers of the SimCAQ project, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting merge requests, providing feedback in comments, and any other activities.
Communication through any of SimCAQ's channels (GitLab, Mattermos, mailing lists, etc.) must be constructive and never resort to personal attacks, trolling, public or private harrassment, insults, or other unprofessional conduct.
We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the SimCAQ project to do the same.
If any member of the community violates this code of conduct, the maintainers of the SimCAQ project may take action, removing issues, comments, and MRs or blocking accounts as deemed appropriate.
If you are subject to or witness unacceptable behavior, or have any other concerns, please contact us.
\ No newline at end of file
# Contributing to SimCAQ API
## Before you get started
### Code of Conduct
By participating of this project you are expected to hold the [Code of Conduct](https://gitlab.c3sl.ufpr.br/simcaq/simcaq-node/blob/development/CODE_OF_CONDUCT.md).
## How Can I Contribute?
### Reporting Bugs
Bugs are reported and tracked at [simcaq/SCRUM](https://gitlab.c3sl.ufpr.br/simcaq/SCRUM/board) repository. As you determinate which repository your bug is related to, create an issue and label it with the appropriate tags.
## Branch structure
* **master**: protected branch and contains the stable version
* **development**: default branch
* **issue/??**: issue branch - a branch created to solve a issue
* **feature_????**: feature branch - a branch created to add a feature
* **hotfix_????**: hotfix branch - a branch created to fix a problem or error
* **release_vM.m.f**: release branch - a branch created to merge with master and set a release. The verion follows the [semantic versioning](http://semver.org)
## Styleguide
### Commit messages
* Use the present tense ("Add feature" not "Added feature")
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
* Limit the first line to 72 characters or less
* Reference issues and pull requests liberally
* When only changing documentation, include [ci skip] in the commit description
* Consider starting the commit message with an applicable emoji:
* :art: `:art:` when improving the format/structure of the code
* :racehorse: `:racehorse:` when improving performance
* :memo: `:memo:` when writing docs
* :bug: `:bug:` when fixing a bug
* :fire: `:fire:` when removing code or files
* :green_heart: `:green_heart:` when fixing the CI build
* :white_check_mark: `:white_check_mark:` when adding tests
* :lock: `:lock:` when dealing with security
* :arrow_up: `:arrow_up:` when upgrading dependencies
* :arrow_down: `:arrow_down:` when downgrading dependencies
### JavaScript Styleguide
All JavaScript follows the [AirBnB styleguide](https://github.com/airbnb/javascript) with the following modifications:
* 4 spaces of identation
* No unused vars
* Allow param reassign
This diff is collapsed.
# SIMCAQ
[![build status](https://gitlab.c3sl.ufpr.br/simcaq/simcaq-node/badges/development/build.svg)](https://gitlab.c3sl.ufpr.br/simcaq/simcaq-node/commits/development)
[![coverage report](https://gitlab.c3sl.ufpr.br/simcaq/simcaq-node/badges/development/coverage.svg)](https://gitlab.c3sl.ufpr.br/simcaq/simcaq-node/commits/development)
# Dependencies
Previous versions of Node.js do not support ECMAScript6, it is recommended to use **at least** version 4.5.0LTS.
1) Install [NVM (Node Version Manager)](https://github.com/creationix/nvm)
2) Install Node.js via NVM
> source ~/.bashrc
> nvm install v4.5.0
3) Enable Node.js
> nvm use v4.5.0
4) Install the global dependencies
> npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint istanbul
5) Install project dependencies
> npm install
6) Copy `config.json.example` to `config.json`
> cp config.json.example config.json
{
"port": 3000,
"monetdb": {
"host": "simcaqdb1",
"port": 50000,
"dbname": "simcaq_dev",
"user": "monetdb",
"password":"monetdb"
},
"default": {
"api": {
"version" : "v1"
}
}
}
{
"tags": {
"allowUnknownTags": true
},
"plugins": [
"plugins/markdown"
],
"opts": {
"template": "./node_modules/docdash/",
"encoding": "utf8",
"destination": "docs/",
"recurse": true,
"verbose": true
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
}
}
var express = require('express')
var path = require('path')
var cookieParser = require('cookie-parser')
var bodyParser = require('body-parser')
var methodOverride = require('method-override')
var libs = process.cwd() + '/libs/'
var config = require('./config')
var log = require('./log')(module)
var api = require('./routes/api')
var app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(methodOverride())
app.use('/api/v1/', api)
// catch 404 and forward to error handler
app.use(function(req, res, next){
res.status(404)
log.debug('%s %d %s', req.method, res.statusCode, req.url)
res.json({
error: 'Not found'
})
return
})
// error handlers
app.use(function(err, req, res, next){
res.status(err.status || 500)
log.error('%s %d %s', req.method, res.statusCode, err.message)
res.json({
error: err.message
})
return
})
module.exports = app
var nconf = require('nconf')
nconf.argv()
.env()
.file({
file: process.cwd() + '/config.json'
})
module.exports = nconf
var mdb = require('monetdb')()
var libs = process.cwd() + '/libs/'
var log = require(libs + 'log')(module)
var config = require(libs + 'config')
var options = {
host: config.get('monetdb:host'),
port: config.get('monetdb:port'),
dbname: config.get('monetdb:dbname'),
user: config.get('monetdb:user'),
password: config.get('monetdb:password')
}
var conn = new mdb(options)
conn.connect()
module.exports = conn
var winston = require('winston')
winston.emitErrs = true
function logger(module) {
return new winston.Logger({
transports : [
// new winston.transports.File({
// level: 'info',
// filename: process.cwd() + '/logs/all.log',
// handleException: true,
// json: true,
// maxSize: 5242880, //5mb
// maxFiles: 2,
// colorize: false
// }),
new winston.transports.Console({
level: 'debug',
label: getFilePath(module),
handleException: true,
json: false,
colorize: true
})
],
exitOnError: false
})
}
function getFilePath (module ) {
//using filename in log statements
return module.filename.split('/').slice(-2).join('/')
}
module.exports = logger
var express = require('express')
var router = express.Router()
var libs = process.cwd() + '/libs/'
var log = require(libs + 'log')(module)
var config = require(libs + 'config')
var conn = require(libs + 'db/monet')
router.get('/', function (req, res) {
res.json({
msg: 'SimCAQ API is running'
})
})
router.get('/data', function(req, res) {
console.log(req.query)
console.log(req.query.met)
console.log(req.query.dim)
conn.query(
'SELECT * FROM turmas'
).then(function(result) {
res.json({
result: result
})
})
})
router.get('/matriculas', function(req, res) {
console.log(req.query);
tbl_name = "matriculas";
switch(req.query.agregar)
{
case "estado":
tbl_name = "matriculas_estado";
break;
case "regiao":
tbl_name = "matriculas_regiao";
break;
}
console.log("Querying table '" + tbl_name + "'");
/* FIXME: Replace parameter substitution
- Might not be needed since the parameter tbl_name is not supplied by the user */
conn.query(
'SELECT * FROM ' + tbl_name, true
).then(function(result) {
console.log(result);
res.json({
result: result.data
})
});
})
module.exports = router
......@@ -4,20 +4,102 @@
"author": "C3SL",
"description": "Simulador custo aluno-qualidade",
"private": true,
"engines": {
"node": ">= 6.8.1"
},
"engineStrict": true,
"scripts": {
"start": "nodemon server.js || node server.js",
"configure": "node generateData.js"
"start": "cd build && forever start server.js || node server.js",
"test": "cd build && mocha"
},
"dependencies": {
"body-parser": "^1.13.1",
"agenda": "^0.9.1",
"apicache": "0.7.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"bcrypt": "^5.1.0",
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.18.3",
"chai": "^3.5.0",
"chai-http": "^3.0.0",
"chai-xml": "^0.3.2",
"chalk": "^1.1.3",
"cookie-parser": "^1.3.5",
"debug": "~2.0.x",
"express": "^4.13.0",
"faker": "^2.1.5",
"method-override": "^2.3.3",
"monetdb": "^1.1.2",
"nconf": "^0.6.x",
"winston": "^0.8.x"
"cors": "^2.8.4",
"csv-express": "^1.2.2",
"debug": "~2.3.x",
"dirty-chai": "^1.2.2",
"eslint": "^3.19.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^6.10.3",
"express": "^4.16.4",
"forever": "^0.15.2",
"gulp-babel": "^6.1.3",
"gulp-cli": "^1.4.0",
"gulp-function": "^2.2.14",
"gulp-istanbul": "^1.1.3",
"gulp-plumber": "^1.2.0",
"gulp-rename": "^1.4.0",
"gulp-uglify": "^2.1.2",
"js2xmlparser": "^2.0.2",
"jsdoc": "^3.5.5",
"jsonexport": "^2.3.0",
"jwt-simple": "^0.5.5",
"lodash": "^4.17.11",
"method-override": "^2.3.10",
"mocha": "^3.5.3",
"monetdb-pool": "0.0.8",
"mongoose": "^4.13.17",
"multer": "^1.4.5-lts.1",
"natives": "^1.1.6",
"nconf": "^0.8.5",
"node-uuid": "^1.4.8",
"nodemailer": "^4.6.8",
"nodemailer-html-to-text": "^2.1.0",
"oauth2orize": "^1.11.0",
"passport": "^0.3.2",
"passport-http-bearer": "^1.0.1",
"passport-oauth2-client-password": "^0.1.2",
"pg": "^8.10.0",
"request": "^2.88.0",
"sequelize": "^6.31.0",
"sequelize-cli": "^6.6.0",
"sqlstring": "^2.3.1",
"squel": "^5.12.2",
"winston": "^2.4.4"
},
"license": "MIT"
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.13.2",
"babel-register": "^6.14.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"chai-xml": "^0.3.1",
"docdash": "^0.4.0",
"eslint": "^3.7.1",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-cli": "^1.2.2",
"gulp-docco": "0.0.4",
"gulp-eslint": "^3.0.1",
"gulp-file-cache": "0.0.1",
"gulp-function": "^2.2.0",
"gulp-istanbul": "^1.1.1",
"gulp-jsdoc3": "^1.0.1",
"gulp-mocha": "^3.0.1",
"gulp-nodemon": "^2.1.0",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^2.0.0",
"jsdoc": "^3.4.1",
"mkdirp": "^0.5.1"
}
}
var debug = require('debug')('node-express-base')
var libs = process.cwd() + '/libs/'
var config = require(libs + 'config')
var log = require(libs + 'log')(module)
var app = require(libs + 'app')
app.set('port', config.get('port') || 3000)
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port)
log.info('Express server listening on port ' + config.get('port'))
})
*downloads.js
*resetToken.js (V)
*pqr.js
*simulation.js
*user.js (V)
*verifyToken.js (V)
const express = require('express');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const cors = require('cors');
const squel = require('squel');
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const config = require(`${libs}/config`);
const app = express();
const api_v1 = require('./routes_v1/api');
const api_v2 = require('./routes_v2/api');
const passport = require('passport');
require(`${libs}/middlewares/passport`);
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({ extended: true, limit: '50mb' }));
app.use(cookieParser());
// Enable Cross-Origin Resource Sharing (CORS)
app.use(cors());
app.use(methodOverride());
// Middleware tha adds the squel object to req
app.use((req, res, next) => {
req.resetSql = () => {
req.sql = squel.select();
// HACK to know wich table we are using
req.sql.oldFrom = req.sql.from;
req.sql.from = (name, alias = null) => {
req.sql.oldFrom(name, alias || null);
req.sql.tableFrom = name;
return req.sql;
};
};
req.resetSql();
req.sql.oldClone = req.sql.clone;
req.sql.clone = () => {
let cloned = req.sql.oldClone();
cloned.oldFrom = cloned.from;
cloned.from = (name, alias = null) => {
cloned.oldFrom(name, alias || null);
cloned.tableFrom = name;
return cloned;
};
return cloned;
};
next();
});
app.use(passport.initialize());
app.use(passport.session());
app.use((req, res, next) => {
res.setHeader('Last-Modified', (new Date()).toUTCString());
next();
});
// Mounts all API routes under /api/v1
app.use('/api/v1', api_v1);
// Mounts all API routes under /api/v2
app.use('/api/v2', api_v2);
// Catch 404 and forward to error handler
app.use((req, res, next) => {
res.status(404);
log.error('%s %d %s', req.method, res.statusCode, req.url);
res.json({ error: 'Error 404: Page not found' }).end();
});
// Express' default error handler
app.use((err, req, res, next) => {
res.status(err.status || 500);
log.error('%s %d %s', req.method, res.statusCode, err.message);
log.error(`Route: ${req.originalUrl}`);
log.error(err);
res.json({ error: err.message }).end();
});
module.exports = app;