-
João Victor Tozatti Risso authored
Signed-off-by:
João Victor Tozatti Risso <jvtr12@inf.ufpr.br>
João Victor Tozatti Risso authoredSigned-off-by:
João Victor Tozatti Risso <jvtr12@inf.ufpr.br>
state.js 812 B
const express = require('express');
const stateApp = express();
const libs = `${process.cwd()}/libs`;
const squel = require('squel');
const query = require(`${libs}/middlewares/query`);
const response = require(`${libs}/middlewares/response`);
stateApp.get('/', (req, res, next) => {
req.query = squel.select().from('estados').toParam();
next();
}, query, response);
stateApp.get('/:id', (req, res, next) => {
req.query = squel.select().from('estados').where('pk_estado_id = ?',
parseInt(req.params.id, 10)).toParam();
next();
}, query, response);
stateApp.get('/region/:id', (req, res, next) => {
req.query = squel.select().from('estados').where('fk_regiao_id = ?',
parseInt(req.params.id, 10)).toParam();
next();
}, query, response);
module.exports = stateApp;