Last active
September 6, 2020 11:36
-
-
Save julioflima/05040eb8f2268fe5f7de6e88ad1588ff to your computer and use it in GitHub Desktop.
Routes become a map with the split of validations, rule added and two validations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { celebrate } = require('celebrate'); | |
const express = require('express'); | |
const SensorDTO = require('../model/SensorDTO'); | |
const SensorRule = require('../rule/SensorRule'); | |
const SensorController = require('../controller/SensorController'); | |
module.exports = class Routes { | |
constructor() { | |
this.routes = express.Router(); | |
return this.init(); | |
} | |
init() { | |
this.map() | |
return this.routes | |
} | |
map() { | |
this.routes.get('/sensor', celebrate(SensorDTO.getSensor()), SensorController.index); | |
this.routes.post('/sensor', celebrate(SensorDTO.postSensor()), SensorRule.date, celebrate(SensorDTO.ruleDate()), SensorController.store); | |
this.routes.delete('/sensor', celebrate(SensorDTO.deleteSensor()), SensorController.delete); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment