backend api refactoring

This commit is contained in:
GotPPay
2018-01-15 16:06:37 +01:00
parent 49d30f00f8
commit e1f315cb81
2 changed files with 5 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
var express = require ('express'), router = express.Router ();
router.use ('/getSkill', require ('./skill'));
router.use ('/updateSkill', require ('./skill')); // this will be fixed in next code refactoring
router.use ('/skill', require ('./skill'));
module.exports = router;

View File

@@ -22,7 +22,7 @@ router.get ('/:id', async (req, res, next) => {
}
});
router.post ('/:id', bodyParser.json (), async (req, res, next) => {
router.put ('/:id', bodyParser.json (), async (req, res, next) => {
let id = req.params.id;
let dataFromWeb = JSON.stringify (req.body);
let skill = JSON.parse (dataFromWeb);
@@ -33,7 +33,9 @@ router.post ('/:id', bodyParser.json (), async (req, res, next) => {
console.log ('id = ' + id);
if (id !== '-1') {
//TODO : Fix inconsistency ! If skill is sent to amazon and accepted, but
//fails in database (ID doesn't exist)
if (id.length === constants.skillIDLength) {
if (updateOnAmazon) {
amazonHelper
.updateSkill (skill)