Merged 0.14.1
parent
781974b8e7
commit
ceb8b00e1f
@ -1,17 +0,0 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# For the full list of supported browsers by the Angular framework, please see:
|
||||
# https://angular.io/guide/browser-support
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
last 1 Chrome version
|
||||
last 1 Firefox version
|
||||
last 2 Edge major versions
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
Firefox ESR
|
||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
@ -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["ISSUER"] = "issuer";
|
||||
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, issuer, description, lastUpdatedAt) {
|
||||
this.bolt12 = bolt12;
|
||||
this.amountmSat = amountmSat;
|
||||
this.amountMSat = amountMSat;
|
||||
this.title = title;
|
||||
this.vendor = vendor;
|
||||
this.issuer = issuer;
|
||||
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 = { ...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,12 @@
|
||||
export var ECLWSEventsEnum;
|
||||
(function (ECLWSEventsEnum) {
|
||||
ECLWSEventsEnum["PAY_RECEIVED"] = "payment-received";
|
||||
ECLWSEventsEnum["PAY_RELAYED"] = "payment-relayed";
|
||||
ECLWSEventsEnum["PAY_SENT"] = "payment-sent";
|
||||
ECLWSEventsEnum["PAY_SETTLING_ONCHAIN"] = "payment-settling-onchain";
|
||||
ECLWSEventsEnum["PAY_FAILED"] = "payment-failed";
|
||||
ECLWSEventsEnum["CHANNEL_OPENED"] = "channel-opened";
|
||||
ECLWSEventsEnum["CHANNEL_STATE_CHANGED"] = "channel-state-changed";
|
||||
ECLWSEventsEnum["CHANNEL_CLOSED"] = "channel-closed";
|
||||
ECLWSEventsEnum["ONION_MESSAGE_RECEIVED"] = "onion-message-received";
|
||||
})(ECLWSEventsEnum || (ECLWSEventsEnum = {}));
|
@ -1,11 +1,12 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getChannels, getChannelStats, openChannel, updateChannelRelayFee, closeChannel } from '../../controllers/eclair/channels.js';
|
||||
import { getChannels, getChannelStats, openChannel, updateChannelRelayFee, closeChannel, circularRebalance } from '../../controllers/eclair/channels.js';
|
||||
const router = Router();
|
||||
router.get('/', isAuthenticated, getChannels);
|
||||
router.get('/stats', isAuthenticated, getChannelStats);
|
||||
router.post('/', isAuthenticated, openChannel);
|
||||
router.post('/updateRelayFee', isAuthenticated, updateChannelRelayFee);
|
||||
router.post('/circularRebalance', circularRebalance);
|
||||
router.delete('/', isAuthenticated, closeChannel);
|
||||
export default router;
|
||||
|
@ -1,7 +1,8 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { getNodes } from '../../controllers/eclair/network.js';
|
||||
import { getNodes, findRouteBetweenNodes } from '../../controllers/eclair/network.js';
|
||||
const router = Router();
|
||||
router.get('/nodes/:id', isAuthenticated, getNodes);
|
||||
router.get('/routebetweennodes', isAuthenticated, findRouteBetweenNodes);
|
||||
export default router;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import exprs from 'express';
|
||||
const { Router } = exprs;
|
||||
import { isAuthenticated } from '../../utils/authCheck.js';
|
||||
import { queryPaymentRoute, decodePayment, getSentPaymentsInformation, postPayment } from '../../controllers/eclair/payments.js';
|
||||
import { queryPaymentRoute, decodePayment, getSentPaymentsInformation, postPayment, sendPaymentToRoute } from '../../controllers/eclair/payments.js';
|
||||
const router = Router();
|
||||
router.get('/route/', isAuthenticated, queryPaymentRoute);
|
||||
router.get('/decode/:invoice', isAuthenticated, decodePayment);
|
||||
router.post('/getsentinfos', isAuthenticated, getSentPaymentsInformation);
|
||||
router.post('/sendtoroute', isAuthenticated, sendPaymentToRoute);
|
||||
router.post('/', isAuthenticated, postPayment);
|
||||
export default router;
|
||||
|
@ -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 it is too large
Load Diff
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue