@@ -15,7 +15,7 @@ constants.apiResultCodes = {
|
||||
ok:0,
|
||||
amazonError:1,
|
||||
databaseError:2,
|
||||
|
||||
IDLengthError:3,
|
||||
}
|
||||
|
||||
constants.skillIDLength = 24;
|
||||
|
||||
@@ -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)
|
||||
@@ -84,7 +86,7 @@ router.post ('/:id', bodyParser.json (), async (req, res, next) => {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
//no new skills for now
|
||||
res.json ({result: constants.IDLengthError, message: ''});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
import {BASE_URL} from '../config/config';
|
||||
|
||||
export const getAllIntents = (id)=>{
|
||||
let url = `http://${BASE_URL}/intents/${id}`
|
||||
return fetch(url, {method: 'GET'});
|
||||
}
|
||||
|
||||
export const getSkill = (id)=>{
|
||||
let url = `http://${BASE_URL}/getSkill/${id}`
|
||||
return fetch(url, {method: 'GET'});
|
||||
}
|
||||
|
||||
export const deleteSkill = (id)=>{
|
||||
let url = `http://${BASE_URL}/deleteSkill/${id}`
|
||||
let url = `http://${BASE_URL}/skill/${id}`
|
||||
return fetch(url, {method: 'GET'});
|
||||
}
|
||||
|
||||
export const updateSkill = (skill)=>{
|
||||
let id = (skill._id) ? skill._id : -1;
|
||||
let url = `http://${BASE_URL}/updateSkill/${id}`
|
||||
let url = `http://${BASE_URL}/skill/${id}`
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user