diff --git a/.gitignore b/.gitignore index 2d98beead909ceb03087bc85133de73ca5a3bde4..2fa21185e28b55b01382a70bdf4fbd61f652e8f0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ package-lock.json Dockerfile DockerfileAntigo src/libs/db/postgres.js +docker-compose.yml +entrypoint.sh +gulpfile.template.js + diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 85266ff985a71c7c1d0a0933785b77be4d3d3c3d..0000000000000000000000000000000000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - simcaq-node: - container_name: simcaq-node - build: . - ports: - - '3000:3000' - develop: - watch: - - action: sync - path: . - target: /API diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 04db51922c7afe6455aa25ef452e79ead0cd5751..0000000000000000000000000000000000000000 --- a/entrypoint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -echo "Starting simcaq-node" -gulp watch &> /dev/null & -cd build -NODE_ENV=production gulp run diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 1d0724e16a18a88b11333f3564a763ebe1452d83..7c8b741852d94433abf9034871069a8d0594e315 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -43,12 +43,12 @@ gulp.task('compile', ['lint'], () => { gulp.src('src/**/*.js') .pipe(cache.filter()) // cache source files .pipe(babel()) // compile only modified files - .pipe(cache.cache()) // cache compiled files + // .pipe(cache.cache()) // cache compiled files .pipe(gulp.dest('build')); // move compiled files to build directory }); gulp.task('build', ['compile'], () => { - var filesToCopy = [ 'config.json', 'package.json', '.eslintignore', '.eslintrc.json' ]; + var filesToCopy = [ 'config.json', 'package.json' ]; // copy configuration file to build directory gulp.src(filesToCopy) .pipe(gulp.dest('build')); @@ -93,16 +93,25 @@ gulp.task('test', ['pre-test'], () => { }); }); -gulp.task('watch', () => { +gulp.task('watch', ['compile'], () => { console.log('Watching source directory for changes'); - return gulp.watch('src/**/*.js').on('change', () => { + gulp.watch('src/**/*.js').on('change', () => { console.log('Recompiling source'); gulp.start('compile'); console.log('Source recompilation done'); }); }); -gulp.task('default', () => { - console.log("Não execuatar apenas gulp, execute da forma:"); - console.log("\t\tgulp <task>"); +gulp.task('run', () => { + process.chdir('build'); + nodemon({ + script: 'server.js', + tasks: ['watch'], + ignore: ["test/test.js", "gulpfile.babel.js"], + ext: 'js html json', + env: { 'NODE_ENV': process.env.NODE_ENV } + }); }); + +gulp.task('default', ['run']); + diff --git a/gulpfile.template.js b/gulpfile.template.js deleted file mode 100644 index 3de679df0c18e307b692cb22a3cb6446c052fcaf..0000000000000000000000000000000000000000 --- a/gulpfile.template.js +++ /dev/null @@ -1,20 +0,0 @@ -const gulp = require('gulp'); - -const nodemon = require('gulp-nodemon'); - -gulp.task('run', () => { - // process.chdir('build'); - nodemon({ - script: 'server.js', - // tasks: ['watch'], - ignore: ["test/test.js", "gulpfile.babel.js"], - ext: 'js html json', - env: { 'NODE_ENV': process.env.NODE_ENV } - }); -}); - -gulp.task('default', () => { - console.log("Não execuatar apenas gulp, execute da forma:"); - console.log("\t\tgulp <task>"); -}); - diff --git a/src/libs/routes_v1/schoolProfessors.js b/src/libs/routes_v1/schoolProfessors.js new file mode 100644 index 0000000000000000000000000000000000000000..8e80d2d10d2af39758ddd8809ed42eedcc6aa40f --- /dev/null +++ b/src/libs/routes_v1/schoolProfessors.js @@ -0,0 +1,50 @@ +/* +Copyright (C) 2024 Centro de Computacao Cientifica e Software Livre +Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + +This file is part of simcaq-node. + +simcaq-node is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +simcaq-node is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. +*/ + +const express = require('express'); + +const SchoolProfessorsApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const config = require(`${libs}/config`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); + +SchoolProfessorsApp.use(cache('15 day')); + +SchoolProfessorsApp.get('/', (req, res, next) => { + req.sql.from('pnad_novo') + .field('sum(num_doc_ed_basica)', 'escola_agregada') + next(); +}, query, response('years')); +