Merge pull request #1137 from Ride-The-Lightning/Release-0.13.2
Release 0.13.2pull/1140/head v0.13.2
commit
04f909329e
@ -0,0 +1,23 @@
|
||||
name: Pull Request Stats
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, 'Release-*' ]
|
||||
tags: [ 'v*' ]
|
||||
release:
|
||||
types: [released]
|
||||
# Triggers the workflow only when merging pull request to the branches.
|
||||
pull_request:
|
||||
types: [opened, closed]
|
||||
branches: [ master, 'Release-*', '*' ]
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
stats:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Run pull request stats
|
||||
uses: flowwer-dev/pull-request-stats@master
|
||||
with:
|
||||
period: 365
|
@ -0,0 +1,33 @@
|
||||
import { Database } from '../../utils/database.js';
|
||||
import { Logger } from '../../utils/logger.js';
|
||||
import { Common } from '../../utils/common.js';
|
||||
import { CollectionsEnum } from '../../models/database.model.js';
|
||||
const logger = Logger;
|
||||
const common = Common;
|
||||
const databaseService = Database;
|
||||
export const getPageSettings = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Getting Page Settings..' });
|
||||
databaseService.find(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS).then((settings) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Page Settings Received', data: settings });
|
||||
res.status(200).json(settings);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Page Settings', 'Page Settings Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
};
|
||||
export const savePageSettings = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Saving Page Settings..' });
|
||||
// eslint-disable-next-line arrow-body-style
|
||||
return Promise.all(req.body.map((page) => databaseService.validateDocument(CollectionsEnum.PAGE_SETTINGS, page))).then((values) => {
|
||||
return databaseService.insert(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS, req.body).then((insertRes) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Page Settings Updated', data: insertRes });
|
||||
res.status(201).json(insertRes);
|
||||
}).catch((insertErrRes) => {
|
||||
const err = common.handleError(insertErrRes, 'Page Settings', 'Page Settings Update Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Page Settings', 'Page Settings Validation Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
};
|
@ -1,38 +1,139 @@
|
||||
export var CollectionsEnum;
|
||||
(function (CollectionsEnum) {
|
||||
CollectionsEnum["OFFERS"] = "Offers";
|
||||
})(CollectionsEnum || (CollectionsEnum = {}));
|
||||
export var OfferFieldsEnum;
|
||||
(function (OfferFieldsEnum) {
|
||||
OfferFieldsEnum["BOLT12"] = "bolt12";
|
||||
OfferFieldsEnum["AMOUNTMSAT"] = "amountmSat";
|
||||
OfferFieldsEnum["AMOUNTMSAT"] = "amountMSat";
|
||||
OfferFieldsEnum["TITLE"] = "title";
|
||||
OfferFieldsEnum["VENDOR"] = "vendor";
|
||||
OfferFieldsEnum["DESCRIPTION"] = "description";
|
||||
})(OfferFieldsEnum || (OfferFieldsEnum = {}));
|
||||
export const CollectionFieldsEnum = Object.assign({}, OfferFieldsEnum);
|
||||
export class Offer {
|
||||
constructor(bolt12, amountmSat, title, vendor, description, lastUpdatedAt) {
|
||||
constructor(bolt12, amountMSat, title, vendor, description, lastUpdatedAt) {
|
||||
this.bolt12 = bolt12;
|
||||
this.amountmSat = amountmSat;
|
||||
this.amountMSat = amountMSat;
|
||||
this.title = title;
|
||||
this.vendor = vendor;
|
||||
this.description = description;
|
||||
this.lastUpdatedAt = lastUpdatedAt;
|
||||
}
|
||||
}
|
||||
export const validateDocument = (collectionName, documentToValidate) => {
|
||||
switch (collectionName) {
|
||||
case CollectionsEnum.OFFERS:
|
||||
return validateOffer(documentToValidate);
|
||||
case CollectionsEnum.PAGE_SETTINGS:
|
||||
return validatePageSettings(documentToValidate);
|
||||
default:
|
||||
return ({ isValid: false, error: 'Collection does not exist' });
|
||||
}
|
||||
};
|
||||
export const validateOffer = (documentToValidate) => {
|
||||
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.BOLT12)) {
|
||||
return ({ isValid: false, error: CollectionFieldsEnum.BOLT12 + 'is mandatory.' });
|
||||
return ({ isValid: false, error: 'Bolt12 is mandatory.' });
|
||||
}
|
||||
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.AMOUNTMSAT)) {
|
||||
return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + 'is mandatory.' });
|
||||
return ({ isValid: false, error: 'Amount mSat is mandatory.' });
|
||||
}
|
||||
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TITLE)) {
|
||||
return ({ isValid: false, error: CollectionFieldsEnum.TITLE + 'is mandatory.' });
|
||||
return ({ isValid: false, error: 'Title is mandatory.' });
|
||||
}
|
||||
if ((typeof documentToValidate[CollectionFieldsEnum.AMOUNTMSAT] !== 'number')) {
|
||||
return ({ isValid: false, error: CollectionFieldsEnum.AMOUNTMSAT + 'should be a number.' });
|
||||
return ({ isValid: false, error: 'Amount mSat should be a number.' });
|
||||
}
|
||||
return ({ isValid: true });
|
||||
};
|
||||
export var SortOrderEnum;
|
||||
(function (SortOrderEnum) {
|
||||
SortOrderEnum["ASCENDING"] = "asc";
|
||||
SortOrderEnum["DESCENDING"] = "desc";
|
||||
})(SortOrderEnum || (SortOrderEnum = {}));
|
||||
export var PageSettingsFieldsEnum;
|
||||
(function (PageSettingsFieldsEnum) {
|
||||
PageSettingsFieldsEnum["PAGE_ID"] = "pageId";
|
||||
PageSettingsFieldsEnum["TABLES"] = "tables";
|
||||
})(PageSettingsFieldsEnum || (PageSettingsFieldsEnum = {}));
|
||||
export var TableSettingsFieldsEnum;
|
||||
(function (TableSettingsFieldsEnum) {
|
||||
TableSettingsFieldsEnum["TABLE_ID"] = "tableId";
|
||||
TableSettingsFieldsEnum["RECORDS_PER_PAGE"] = "recordsPerPage";
|
||||
TableSettingsFieldsEnum["SORT_BY"] = "sortBy";
|
||||
TableSettingsFieldsEnum["SORT_ORDER"] = "sortOrder";
|
||||
TableSettingsFieldsEnum["COLUMN_SELECTION"] = "columnSelection";
|
||||
TableSettingsFieldsEnum["COLUMN_SELECTION_SM"] = "columnSelectionSM";
|
||||
})(TableSettingsFieldsEnum || (TableSettingsFieldsEnum = {}));
|
||||
export class TableSetting {
|
||||
constructor(tableId, recordsPerPage, sortBy, sortOrder, columnSelection) {
|
||||
this.tableId = tableId;
|
||||
this.recordsPerPage = recordsPerPage;
|
||||
this.sortBy = sortBy;
|
||||
this.sortOrder = sortOrder;
|
||||
this.columnSelection = columnSelection;
|
||||
}
|
||||
}
|
||||
export class PageSettings {
|
||||
constructor(pageId, tables) {
|
||||
this.pageId = pageId;
|
||||
this.tables = tables;
|
||||
}
|
||||
}
|
||||
export const validatePageSettings = (documentToValidate) => {
|
||||
let errorMessages = '';
|
||||
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.PAGE_ID)) {
|
||||
errorMessages = errorMessages + 'Page ID is mandatory.';
|
||||
}
|
||||
if (!documentToValidate.hasOwnProperty(CollectionFieldsEnum.TABLES)) {
|
||||
errorMessages = errorMessages + 'Tables is mandatory.';
|
||||
}
|
||||
const tablesMessages = documentToValidate.tables.reduce((tableAcc, table, tableIdx) => {
|
||||
let errMsg = '';
|
||||
if (!table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID)) {
|
||||
errMsg = errMsg + 'Table ID is mandatory.';
|
||||
}
|
||||
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_BY)) {
|
||||
errMsg = errMsg + 'Sort By is mandatory.';
|
||||
}
|
||||
if (!table.hasOwnProperty(CollectionFieldsEnum.SORT_ORDER)) {
|
||||
errMsg = errMsg + 'Sort Order is mandatory.';
|
||||
}
|
||||
if (!table.hasOwnProperty(CollectionFieldsEnum.COLUMN_SELECTION_SM)) {
|
||||
errMsg = errMsg + 'Column Selection (Mobile Resolution) is mandatory.';
|
||||
}
|
||||
if (table[CollectionFieldsEnum.COLUMN_SELECTION_SM].length < 1) {
|
||||
errMsg = errMsg + 'Column Selection (Mobile Resolution) should have at least 1 field.';
|
||||
}
|
||||
if (table[CollectionFieldsEnum.COLUMN_SELECTION_SM].length > 3) {
|
||||
errMsg = errMsg + 'Column Selection (Mobile Resolution) should have maximum 3 fields.';
|
||||
}
|
||||
if (!table.hasOwnProperty(CollectionFieldsEnum.COLUMN_SELECTION)) {
|
||||
errMsg = errMsg + 'Column Selection (Desktop Resolution) is mandatory.';
|
||||
}
|
||||
if (table[CollectionFieldsEnum.COLUMN_SELECTION].length < 2) {
|
||||
errMsg = errMsg + 'Column Selection (Desktop Resolution) should have at least 2 fields.';
|
||||
}
|
||||
if (errMsg.trim() !== '') {
|
||||
tableAcc.push({ table: (table.hasOwnProperty(CollectionFieldsEnum.TABLE_ID) ? table[CollectionFieldsEnum.TABLE_ID] : (tableIdx + 1)), message: errMsg });
|
||||
}
|
||||
return tableAcc;
|
||||
}, []);
|
||||
if (errorMessages.trim() === '' && tablesMessages.length === 0) {
|
||||
return ({ isValid: true });
|
||||
}
|
||||
else {
|
||||
const errObj = { page: (documentToValidate.hasOwnProperty(CollectionFieldsEnum.PAGE_ID) ? documentToValidate[CollectionFieldsEnum.PAGE_ID] : 'Unknown') };
|
||||
if (errorMessages.trim() !== '') {
|
||||
errObj['message'] = errorMessages;
|
||||
}
|
||||
if (tablesMessages.length && tablesMessages.length > 0) {
|
||||
errObj['tables'] = tablesMessages;
|
||||
}
|
||||
return ({ isValid: false, error: JSON.stringify(errObj) });
|
||||
}
|
||||
};
|
||||
export var CollectionsEnum;
|
||||
(function (CollectionsEnum) {
|
||||
CollectionsEnum["OFFERS"] = "Offers";
|
||||
CollectionsEnum["PAGE_SETTINGS"] = "PageSettings";
|
||||
})(CollectionsEnum || (CollectionsEnum = {}));
|
||||
export const CollectionFieldsEnum = Object.assign(Object.assign(Object.assign({}, OfferFieldsEnum), PageSettingsFieldsEnum), TableSettingsFieldsEnum);
|
||||
export const LNDCollection = [CollectionsEnum.PAGE_SETTINGS];
|
||||
export const ECLCollection = [CollectionsEnum.PAGE_SETTINGS];
|
||||
export const CLNCollection = [CollectionsEnum.PAGE_SETTINGS, CollectionsEnum.OFFERS];
|
||||
|
@ -0,0 +1,8 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getPageSettings, savePageSettings } from '../../controllers/shared/pageSettings.js';
|
||||
const router = Router();
|
||||
router.get('/', isAuthenticated, getPageSettings);
|
||||
router.post('/', isAuthenticated, savePageSettings);
|
||||
export default router;
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
(()=>{"use strict";var e,v={},g={};function r(e){var n=g[e];if(void 0!==n)return n.exports;var t=g[e]={id:e,loaded:!1,exports:{}};return v[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}r.m=v,e=[],r.O=(n,t,f,o)=>{if(!t){var a=1/0;for(i=0;i<e.length;i++){for(var[t,f,o]=e[i],c=!0,u=0;u<t.length;u++)(!1&o||a>=o)&&Object.keys(r.O).every(b=>r.O[b](t[u]))?t.splice(u--,1):(c=!1,o<a&&(a=o));if(c){e.splice(i--,1);var d=f();void 0!==d&&(n=d)}}return n}o=o||0;for(var i=e.length;i>0&&e[i-1][2]>o;i--)e[i]=e[i-1];e[i]=[t,f,o]},r.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return r.d(n,{a:n}),n},r.d=(e,n)=>{for(var t in n)r.o(n,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((n,t)=>(r.f[t](e,n),n),[])),r.u=e=>e+"."+{564:"3d38ee9330b2ba94",636:"95c8ae357b1ed820",893:"9a615c46b89a5a79",924:"1c1eb885f1f101d2"}[e]+".js",r.miniCssF=e=>{},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={},n="RTLApp:";r.l=(t,f,o,i)=>{if(e[t])e[t].push(f);else{var a,c;if(void 0!==o)for(var u=document.getElementsByTagName("script"),d=0;d<u.length;d++){var l=u[d];if(l.getAttribute("src")==t||l.getAttribute("data-webpack")==n+o){a=l;break}}a||(c=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",n+o),a.src=r.tu(t)),e[t]=[f];var s=(m,b)=>{a.onerror=a.onload=null,clearTimeout(p);var h=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach(_=>_(b)),m)return m(b)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=s.bind(null,a.onerror),a.onload=s.bind(null,a.onload),c&&document.head.appendChild(a)}}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:n=>n},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={666:0};r.f.j=(f,o)=>{var i=r.o(e,f)?e[f]:void 0;if(0!==i)if(i)o.push(i[2]);else if(666!=f){var a=new Promise((l,s)=>i=e[f]=[l,s]);o.push(i[2]=a);var c=r.p+r.u(f),u=new Error;r.l(c,l=>{if(r.o(e,f)&&(0!==(i=e[f])&&(e[f]=void 0),i)){var s=l&&("load"===l.type?"missing":l.type),p=l&&l.target&&l.target.src;u.message="Loading chunk "+f+" failed.\n("+s+": "+p+")",u.name="ChunkLoadError",u.type=s,u.request=p,i[1](u)}},"chunk-"+f,f)}else e[f]=0},r.O.j=f=>0===e[f];var n=(f,o)=>{var u,d,[i,a,c]=o,l=0;if(i.some(p=>0!==e[p])){for(u in a)r.o(a,u)&&(r.m[u]=a[u]);if(c)var s=c(r)}for(f&&f(o);l<i.length;l++)r.o(e,d=i[l])&&e[d]&&e[d][0](),e[d]=0;return r.O(s)},t=self.webpackChunkRTLApp=self.webpackChunkRTLApp||[];t.forEach(n.bind(null,0)),t.push=n.bind(null,t.push.bind(t))})()})();
|
||||
(()=>{"use strict";var e,v={},g={};function r(e){var n=g[e];if(void 0!==n)return n.exports;var t=g[e]={id:e,loaded:!1,exports:{}};return v[e].call(t.exports,t,t.exports,r),t.loaded=!0,t.exports}r.m=v,e=[],r.O=(n,t,f,o)=>{if(!t){var a=1/0;for(i=0;i<e.length;i++){for(var[t,f,o]=e[i],c=!0,u=0;u<t.length;u++)(!1&o||a>=o)&&Object.keys(r.O).every(b=>r.O[b](t[u]))?t.splice(u--,1):(c=!1,o<a&&(a=o));if(c){e.splice(i--,1);var l=f();void 0!==l&&(n=l)}}return n}o=o||0;for(var i=e.length;i>0&&e[i-1][2]>o;i--)e[i]=e[i-1];e[i]=[t,f,o]},r.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return r.d(n,{a:n}),n},r.d=(e,n)=>{for(var t in n)r.o(n,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((n,t)=>(r.f[t](e,n),n),[])),r.u=e=>e+"."+{258:"fb8729850462aa0e",267:"4a643eeda98f6031",564:"c60bd98c3a9d472b",636:"2c7ab7c33992b609"}[e]+".js",r.miniCssF=e=>{},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={},n="RTLApp:";r.l=(t,f,o,i)=>{if(e[t])e[t].push(f);else{var a,c;if(void 0!==o)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var d=u[l];if(d.getAttribute("src")==t||d.getAttribute("data-webpack")==n+o){a=d;break}}a||(c=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.setAttribute("data-webpack",n+o),a.src=r.tu(t)),e[t]=[f];var s=(m,b)=>{a.onerror=a.onload=null,clearTimeout(p);var h=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach(_=>_(b)),m)return m(b)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=s.bind(null,a.onerror),a.onload=s.bind(null,a.onload),c&&document.head.appendChild(a)}}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:n=>n},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("angular#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="",(()=>{var e={666:0};r.f.j=(f,o)=>{var i=r.o(e,f)?e[f]:void 0;if(0!==i)if(i)o.push(i[2]);else if(666!=f){var a=new Promise((d,s)=>i=e[f]=[d,s]);o.push(i[2]=a);var c=r.p+r.u(f),u=new Error;r.l(c,d=>{if(r.o(e,f)&&(0!==(i=e[f])&&(e[f]=void 0),i)){var s=d&&("load"===d.type?"missing":d.type),p=d&&d.target&&d.target.src;u.message="Loading chunk "+f+" failed.\n("+s+": "+p+")",u.name="ChunkLoadError",u.type=s,u.request=p,i[1](u)}},"chunk-"+f,f)}else e[f]=0},r.O.j=f=>0===e[f];var n=(f,o)=>{var u,l,[i,a,c]=o,d=0;if(i.some(p=>0!==e[p])){for(u in a)r.o(a,u)&&(r.m[u]=a[u]);if(c)var s=c(r)}for(f&&f(o);d<i.length;d++)r.o(e,l=i[d])&&e[l]&&e[l][0](),e[l]=0;return r.O(s)},t=self.webpackChunkRTLApp=self.webpackChunkRTLApp||[];t.forEach(n.bind(null,0)),t.push=n.bind(null,t.push.bind(t))})()})();
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
import { Database, DatabaseService } from '../../utils/database.js';
|
||||
import { Logger, LoggerService } from '../../utils/logger.js';
|
||||
import { Common, CommonService } from '../../utils/common.js';
|
||||
import { CollectionsEnum, PageSettings } from '../../models/database.model.js';
|
||||
|
||||
const logger: LoggerService = Logger;
|
||||
const common: CommonService = Common;
|
||||
const databaseService: DatabaseService = Database;
|
||||
|
||||
export const getPageSettings = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Getting Page Settings..' });
|
||||
databaseService.find(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS).then((settings: PageSettings) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Page Settings Received', data: settings });
|
||||
res.status(200).json(settings);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Page Settings', 'Page Settings Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
};
|
||||
|
||||
export const savePageSettings = (req, res, next) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Saving Page Settings..' });
|
||||
// eslint-disable-next-line arrow-body-style
|
||||
return Promise.all(req.body.map((page) => databaseService.validateDocument(CollectionsEnum.PAGE_SETTINGS, page))).then((values) => {
|
||||
return databaseService.insert(req.session.selectedNode, CollectionsEnum.PAGE_SETTINGS, req.body).then((insertRes) => {
|
||||
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Page Settings', msg: 'Page Settings Updated', data: insertRes });
|
||||
res.status(201).json(insertRes);
|
||||
}).catch((insertErrRes) => {
|
||||
const err = common.handleError(insertErrRes, 'Page Settings', 'Page Settings Update Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Page Settings', 'Page Settings Validation Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ message: err.message, error: err.error });
|
||||
});
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getPageSettings, savePageSettings } from '../../controllers/shared/pageSettings.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', isAuthenticated, getPageSettings);
|
||||
router.post('/', isAuthenticated, savePageSettings);
|
||||
|
||||
export default router;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue