index.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. /**
  2. * API САЙТА lycArch.urfu.ru
  3. * Copyright © 2021, А.М.Гольдин. ISC license
  4. */
  5. "use strict";
  6. // Подключение необходимых модулей API
  7. const modReq = [
  8. "officeEdit", "createFolder", "getArticles", "delArticle", "delFile",
  9. "sendArticle", "loadArticle", "getFields", "goCoAuth", "artInfo",
  10. "artsWork", "sendNotes", "getRevCorr", "setRevCorr", "puplication",
  11. "fullDel", "getRevCorID", "corrEnd", "find"
  12. ];
  13. let mod = {};
  14. for (let modName of modReq) mod[modName] = require("./" + modName);
  15. module.exports = async (post, user) => {
  16. // Разбираем переданные в аргументе POST-данные
  17. let postDt;
  18. try {postDt = JSON.parse(post);} catch (e) {return "none";}
  19. if (!postDt.f) postDt.f = "noFunc";
  20. // Реализуем соответствующую функцию api в зависимости от переменной f
  21. if (!modReq.includes(postDt.f)) return "none";
  22. let argsObj = postDt.dt || {};
  23. return (await mod[postDt.f](argsObj, user));
  24. }