backend api refactoring
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
var express = require ('express'), router = express.Router ();
|
var express = require ('express'), router = express.Router ();
|
||||||
|
|
||||||
router.use ('/getSkill', require ('./skill'));
|
router.use ('/skill', require ('./skill'));
|
||||||
router.use ('/updateSkill', require ('./skill')); // this will be fixed in next code refactoring
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -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 id = req.params.id;
|
||||||
let dataFromWeb = JSON.stringify (req.body);
|
let dataFromWeb = JSON.stringify (req.body);
|
||||||
let skill = JSON.parse (dataFromWeb);
|
let skill = JSON.parse (dataFromWeb);
|
||||||
@@ -33,7 +33,9 @@ router.post ('/:id', bodyParser.json (), async (req, res, next) => {
|
|||||||
|
|
||||||
console.log ('id = ' + id);
|
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) {
|
if (updateOnAmazon) {
|
||||||
amazonHelper
|
amazonHelper
|
||||||
.updateSkill (skill)
|
.updateSkill (skill)
|
||||||
|
|||||||
Reference in New Issue
Block a user