From 59d56cb2b70c69c8cda840a6a01f5a3d8c6fd9ac Mon Sep 17 00:00:00 2001
From: Rudolf Copi Eckelberg <rce16@inf.ufpr.br>
Date: Thu, 22 Sep 2016 09:31:42 -0300
Subject: [PATCH] Changed express apps for routers

Changing apps to follow suggested practices from documentation
and centralizing prefix /api/v1 in the app module.
---
 src/libs/app.js               |  2 +-
 src/libs/routes/api.js        | 10 +++++-----
 src/libs/routes/city.js       |  2 +-
 src/libs/routes/enrollment.js |  2 +-
 src/libs/routes/region.js     |  2 +-
 src/libs/routes/school.js     |  2 +-
 src/libs/routes/state.js      |  2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/libs/app.js b/src/libs/app.js
index d00a2887..b0390720 100644
--- a/src/libs/app.js
+++ b/src/libs/app.js
@@ -29,7 +29,7 @@ app.use(cors());
 app.use(methodOverride());
 app.use(cache('1 day'));
 app.use(compression(9));
-app.use(api);
+app.use('/api/v1', api);
 
 // catch 404 and forward to error handler
 app.use((req, res, next) => {
diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js
index 06953296..c3a870c6 100644
--- a/src/libs/routes/api.js
+++ b/src/libs/routes/api.js
@@ -17,10 +17,10 @@ api.get('/api/v1', (req, res) => {
 });
 
 // mount API routes
-api.use('/api/v1/enrollment', enrollment);
-api.use('/api/v1/state', state);
-api.use('/api/v1/region', region);
-api.use('/api/v1/city', city);
-api.use('/api/v1/school', school);
+api.use('/enrollment', enrollment);
+api.use('/state', state);
+api.use('/region', region);
+api.use('/city', city);
+api.use('/school', school);
 
 module.exports = api;
diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js
index 030aa3ce..bf60f077 100644
--- a/src/libs/routes/city.js
+++ b/src/libs/routes/city.js
@@ -1,6 +1,6 @@
 const express = require('express');
 
-const cityApp = express();
+const cityApp = express.Router();
 
 const libs = `${process.cwd()}/libs`;
 
diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js
index 0ec49b84..557695b8 100644
--- a/src/libs/routes/enrollment.js
+++ b/src/libs/routes/enrollment.js
@@ -1,6 +1,6 @@
 const express = require('express');
 
-const enrollmentApp = express();
+const enrollmentApp = express.Router();
 
 const libs = `${process.cwd()}/libs`;
 
diff --git a/src/libs/routes/region.js b/src/libs/routes/region.js
index 754cd616..c0e58ca4 100644
--- a/src/libs/routes/region.js
+++ b/src/libs/routes/region.js
@@ -1,6 +1,6 @@
 const express = require('express');
 
-const regionApp = express();
+const regionApp = express.Router();
 
 const libs = `${process.cwd()}/libs`;
 
diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js
index bf3ee4fb..dc6e8ed5 100644
--- a/src/libs/routes/school.js
+++ b/src/libs/routes/school.js
@@ -1,6 +1,6 @@
 const express = require('express');
 
-const schoolApp = express();
+const schoolApp = express.Router();
 
 const libs = `${process.cwd()}/libs`;
 
diff --git a/src/libs/routes/state.js b/src/libs/routes/state.js
index 637149f1..35699576 100644
--- a/src/libs/routes/state.js
+++ b/src/libs/routes/state.js
@@ -1,6 +1,6 @@
 const express = require('express');
 
-const stateApp = express();
+const stateApp = express.Router();
 
 const libs = `${process.cwd()}/libs`;
 
-- 
GitLab