Chargement en cours app/imports/api/restApi.js +8 −1 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff Chargement en cours @@ -29,7 +29,13 @@ import { import ftUploadProxy from './francetransfert/server/rest'; import createUserToken from './users/server/restToken'; import initWidgetApi from './widgetApi'; import { createOneStructure, getStructures, deleteStructure, getOneStructure } from './structures/server/rest'; import { createOneStructure, updateOneStructure, getStructures, deleteStructure, getOneStructure, } from './structures/server/rest'; import { createOneStructureRuleDispatch, getStructureRuleDispatchs, Chargement en cours Chargement en cours @@ -157,6 +163,7 @@ export default function initRestApi() { // Structure restCu.post({ path: '/structures/create', version: '>=1.0.0' }, Meteor.bindEnvironment(createOneStructure)); restCu.post({ path: '/structures/update', version: '>=1.0.0' }, Meteor.bindEnvironment(updateOneStructure)); restCu.post({ path: '/structures', version: '>=1.0.0' }, Meteor.bindEnvironment(getOneStructure)); restCu.get({ path: '/structures', version: '>=1.0.0' }, Meteor.bindEnvironment(getStructures)); restCu.del({ path: '/structures/delete', version: '>=1.0.0' }, Meteor.bindEnvironment(deleteStructure)); Chargement en cours app/imports/api/structures/server/methods.js +12 −0 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff Chargement en cours @@ -521,3 +521,15 @@ if (Meteor.isServer) { 1000, ); } export function _updateStructure(structure, description, content) { logger.info({ message: 'update this structure', scope: 'system', method: '_updateStructure', params: { structure, description, content }, }); validateString(description); validateString(content); Structures.update({ path: structure.path }, { $set: { description, content } }); } app/imports/api/structures/server/rest.js +27 −1 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff import { Meteor } from 'meteor/meteor'; import logger from '../../logging'; import { _createStructure, _deleteStructure } from './methods'; import { _createStructure, _deleteStructure, _updateStructure } from './methods'; import Structures from '../structures'; import { GetStructure } from '../utils'; Chargement en cours Chargement en cours @@ -273,3 +273,29 @@ export async function deleteStructure(req, content) { error.statusCode = 404; throw error; } // sample use: // curl -X POST -H "X-API-KEY: createuser-password" \ // -H "Content-Type: application/json" \ // -d '{"path": "struc1/struc2/struc3", "description":"short description of group structure", "content":"long description of group structure"}' \ // http://localhost:3000/api/structures/update export async function updateOneStructure(req, content) { if ('path' in content && 'description' in content && 'content' in content) { const structure = Structures.findOne({ path: content.path }); if (structure) { try { _updateStructure(structure, content.description, content.content); return {}; } catch (error) { error.statusCode = 500; throw error; } } const error = new Meteor.Error('api.updateOneStructure.structureNotFound', 'Structure Not Found'); error.statusCode = 404; throw error; } const error = new Meteor.Error('api.updateOneStructure.invalidContent', 'Empty or invalid content'); error.statusCode = 400; throw error; } Chargement en cours
app/imports/api/restApi.js +8 −1 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff Chargement en cours @@ -29,7 +29,13 @@ import { import ftUploadProxy from './francetransfert/server/rest'; import createUserToken from './users/server/restToken'; import initWidgetApi from './widgetApi'; import { createOneStructure, getStructures, deleteStructure, getOneStructure } from './structures/server/rest'; import { createOneStructure, updateOneStructure, getStructures, deleteStructure, getOneStructure, } from './structures/server/rest'; import { createOneStructureRuleDispatch, getStructureRuleDispatchs, Chargement en cours Chargement en cours @@ -157,6 +163,7 @@ export default function initRestApi() { // Structure restCu.post({ path: '/structures/create', version: '>=1.0.0' }, Meteor.bindEnvironment(createOneStructure)); restCu.post({ path: '/structures/update', version: '>=1.0.0' }, Meteor.bindEnvironment(updateOneStructure)); restCu.post({ path: '/structures', version: '>=1.0.0' }, Meteor.bindEnvironment(getOneStructure)); restCu.get({ path: '/structures', version: '>=1.0.0' }, Meteor.bindEnvironment(getStructures)); restCu.del({ path: '/structures/delete', version: '>=1.0.0' }, Meteor.bindEnvironment(deleteStructure)); Chargement en cours
app/imports/api/structures/server/methods.js +12 −0 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff Chargement en cours @@ -521,3 +521,15 @@ if (Meteor.isServer) { 1000, ); } export function _updateStructure(structure, description, content) { logger.info({ message: 'update this structure', scope: 'system', method: '_updateStructure', params: { structure, description, content }, }); validateString(description); validateString(content); Structures.update({ path: structure.path }, { $set: { description, content } }); }
app/imports/api/structures/server/rest.js +27 −1 Numéro de ligne d'origine Numéro de ligne de diff Ligne de diff import { Meteor } from 'meteor/meteor'; import logger from '../../logging'; import { _createStructure, _deleteStructure } from './methods'; import { _createStructure, _deleteStructure, _updateStructure } from './methods'; import Structures from '../structures'; import { GetStructure } from '../utils'; Chargement en cours Chargement en cours @@ -273,3 +273,29 @@ export async function deleteStructure(req, content) { error.statusCode = 404; throw error; } // sample use: // curl -X POST -H "X-API-KEY: createuser-password" \ // -H "Content-Type: application/json" \ // -d '{"path": "struc1/struc2/struc3", "description":"short description of group structure", "content":"long description of group structure"}' \ // http://localhost:3000/api/structures/update export async function updateOneStructure(req, content) { if ('path' in content && 'description' in content && 'content' in content) { const structure = Structures.findOne({ path: content.path }); if (structure) { try { _updateStructure(structure, content.description, content.content); return {}; } catch (error) { error.statusCode = 500; throw error; } } const error = new Meteor.Error('api.updateOneStructure.structureNotFound', 'Structure Not Found'); error.statusCode = 404; throw error; } const error = new Meteor.Error('api.updateOneStructure.invalidContent', 'Empty or invalid content'); error.statusCode = 400; throw error; }