Skip to content

Commit

Permalink
add methods in controller
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosZiegler committed Aug 4, 2020
1 parent e5e9dd2 commit afe5126
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 294 deletions.
30 changes: 30 additions & 0 deletions controllers/Controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

module.exports = {
async index(req, res, next) {
try {

res.json({ message: "Ok" })
} catch (error) {
res.json(error)
}
},
async show(req, res, next) {
try {

res.json({ message: "show" })
} catch (error) {
res.status(404).json(error)
}
},
async store(req, res, next) {

res.json({ message: "store" })

},
async destroy(req, res, next) {
res.json({ message: "destroy" })
},
async update(req, res, next) {
res.json({ message: "update" })
}
}
72 changes: 0 additions & 72 deletions controllers/ProfessionalController.js

This file was deleted.

76 changes: 0 additions & 76 deletions controllers/VacancyController.js

This file was deleted.

29 changes: 0 additions & 29 deletions models/Profissional.js

This file was deleted.

32 changes: 0 additions & 32 deletions models/Vacancy.js

This file was deleted.

87 changes: 2 additions & 85 deletions routes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const express = require("express");
const passport = require('passport');
const AuthController = require("./controllers/AuthController");
const VacancyController = require("./controllers/VacancyController");
const ProfessionalController = require("./controllers/ProfessionalController");
const Controller = require("./controllers/Controller");

const routes = express.Router();

Expand All @@ -25,89 +24,7 @@ routes.post("/signup", passport.authenticate('signup', { session: false }), Auth
* description: Sign in with email and password
*
*/
routes.post("/login", AuthController.index);

/**
* @swagger
* /main:
* post:
* description: access the route only with valid token
*
*/
routes.get("/vacancies", passport.authenticate('jwt', { session: false }), VacancyController.index);
/**
* @swagger
* /main:
* post:
* description: access the route only with valid token
*
*/
routes.get("/vacancy/:id", passport.authenticate('jwt', { session: false }), VacancyController.show);
/**
* @swagger
* /vacancy/create:
* post:
* description: access the route only with valid token
*
*/
routes.post("/vacancy/create", passport.authenticate('jwt', { session: false }), VacancyController.store);
/**
* @swagger
* /vacancy/update:
* post:
* description: update a vacancy with Id
*
*/
routes.put("/vacancy/update/:id", passport.authenticate('jwt', { session: false }), VacancyController.update);
/**
* @swagger
* /vacancy/update:
* post:
* description: update a vacancy with Id
*
*/
routes.delete("/vacancy/delete/:id", passport.authenticate('jwt', { session: false }), VacancyController.destroy);

/**
* @swagger
* /main:
* post:
* description: access the route only with valid token
*
*/
routes.get("/professionals", passport.authenticate('jwt', { session: false }), ProfessionalController.index);
/**
* @swagger
* /main:
* post:
* description: access the route only with valid token
*
*/
routes.get("/professional/:id", passport.authenticate('jwt', { session: false }), ProfessionalController.show);
/**
* @swagger
* /vacancy/create:
* post:
* description: access the route only with valid token
*
*/
routes.post("/professional/create", passport.authenticate('jwt', { session: false }), ProfessionalController.store);
/**
* @swagger
* /vacancy/update:
* post:
* description: update a vacancy with Id
*
*/
routes.put("/professional/update/:id", passport.authenticate('jwt', { session: false }), ProfessionalController.update);
/**
* @swagger
* /vacancy/update:
* post:
* description: update a vacancy with Id
*
*/
routes.delete("/professional/delete/:id", passport.authenticate('jwt', { session: false }), ProfessionalController.destroy);
routes.get("/main", Controller.index);


module.exports = routes;

0 comments on commit afe5126

Please sign in to comment.