Skip to content
Snippets Groups Projects
Commit efb30d30 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add educationYears route

parent 1d3f95fa
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
...@@ -68,12 +68,19 @@ module.exports = { ...@@ -68,12 +68,19 @@ module.exports = {
gender, gender,
period, period,
schoolYear, schoolYear,
educationLevel,
educationLevelMod,
educationLevelShort,
admDependency, admDependency,
admDependencyPriv,
location, location,
ruralLocation,
ethnicGroup, ethnicGroup,
agreement, agreement,
booleanVariable, booleanVariable,
educationLevel, educationType,
educationLevelMod, incomeLevel,
educationType citySize,
idhmLevel,
stateName
}; };
...@@ -44,6 +44,8 @@ const oauth2 = require(`${libs}/middlewares/oauth2`); ...@@ -44,6 +44,8 @@ const oauth2 = require(`${libs}/middlewares/oauth2`);
const verifyToken = require(`${libs}/routes/verifyToken`); const verifyToken = require(`${libs}/routes/verifyToken`);
const educationYears = require(`${libs}/routes/educationYears`);
api.get('/', (req, res) => { api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' }); res.json({ msg: 'SimCAQ API is running' });
}); });
...@@ -68,5 +70,6 @@ api.use('/population', population); ...@@ -68,5 +70,6 @@ api.use('/population', population);
api.use('/idhml', idhml); api.use('/idhml', idhml);
api.use('/auth/token', oauth2.token); api.use('/auth/token', oauth2.token);
api.use('/verify', verifyToken); api.use('/verify', verifyToken);
api.use('/educationYears', educationYears);
module.exports = api; module.exports = api;
const express = require('express');
const educationYearsApp = express.Router();
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const response = require(`${libs}/middlewares/response`);
const config = require(`${libs}/config`);
const id2str = require(`${libs}/middlewares/id2str`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
educationYearsApp.use(cache('15 day'));
educationYearsApp.get('/', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 7; ++i) {
let edLvlShort = {
id: i,
name: id2str.educationLevelShort(i),
schoolYears: []
};
for(let j = i*10; j <= (i*10 + 9); ++j) {
let schoolYear = {
id: j,
name: id2str.schoolYear(j)
};
if(schoolYear.name !== id2str.schoolYear(99)) {
edLvlShort.schoolYears.push(schoolYear);
}
}
if(edLvlShort.name !== id2str.schoolYear(99)) {
req.result.push(edLvlShort);
}
}
next();
}, response('educationYears'));
module.exports = educationYearsApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment