backend api refactoring
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user