Skip to content

Commit

Permalink
Merge pull request #1977 from hollaex/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
abeikverdi authored Feb 23, 2023
2 parents ddbfffc + 8b9f8aa commit e3375fe
Show file tree
Hide file tree
Showing 442 changed files with 29,666 additions and 15,340 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:10.24.1-buster-slim
FROM node:16.18.1-buster-slim

RUN apt-get update && \
apt-get install -y curl openssl ca-certificates git python build-essential && \
rm -rf /var/lib/apt/lists/* && \
npm config set unsafe-perm true && \
npm install pm2@3.2.7 sequelize-cli@5.4.0 mocha -g --loglevel=error
npm install pm2@5.2.0 sequelize-cli@6.5.1 mocha -g --loglevel=error

ENV NODE_ENV=production

Expand Down
3 changes: 1 addition & 2 deletions plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"author": "bitHolla",
"license": "ISC",
"scripts": {
"kill-8080": "lsof -ti:8080 | xargs kill || exit 0",
"generate:bundle:production": "npm run remove:dist && cross-env NODE_ENV=production webpack --env.plugin=$npm_config_plugin --mode production",
"generate:bundle:development": "npm run remove:dist && cross-env NODE_ENV=development webpack --env.plugin=$npm_config_plugin --mode development",
"plugin:development": "cross-env NODE_ENV=development concurrently \"npm run webpack:development --plugin=$npm_config_plugin\" \"npm run watch:webview:json --plugin=$npm_config_plugin\" \"npm run watch:config:json --plugin=$npm_config_plugin\" \"npm run server\"",
Expand All @@ -28,7 +27,7 @@
"generate:webview:development": "npm run generate:bundle:development --plugin=$npm_config_plugin && npm run generate:webview:json:clean --plugin=$npm_config_plugin",
"watch:webview:json": "npm run remove:json && onchange -i 'src/plugins/**/assets/*.json' 'src/plugins/**/views/**/*.json' -- npm run generate:webview:json --plugin=$npm_config_plugin",
"watch:config:json": "npm run remove:config && onchange -i 'src/plugins/**/assets/*.json' 'src/plugins/**/views/**/*.json' 'src/plugins/**/server/*' -- npm run generate:config:json --plugin=$npm_config_plugin",
"server": "npm run kill-8080 && node server.js",
"server": "node server.js",
"build": "npm run build:webview --plugin=$npm_config_plugin && npm run generate:plugin:json --plugin=$npm_config_plugin",
"generate:plugin:json": "PLUGIN=$npm_config_plugin node scripts/generatePlugin.js",
"add:webview:bundles": "node scripts/addBundles.js",
Expand Down
5 changes: 0 additions & 5 deletions plugins/src/components/Dialog/DesktopDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Dialog extends PureComponent {
closeButton: PropTypes.func,
onCloseDialog: PropTypes.func,
children: PropTypes.node.isRequired,
disableTheme: PropTypes.bool,
};

onRequestClose = (e) => {
Expand All @@ -30,9 +29,7 @@ class Dialog extends PureComponent {
shouldCloseOnOverlayClick,
showCloseText,
dialogId,
theme,
className,
disableTheme,
bodyOpenClassName,
strings: STRINGS,
} = this.props;
Expand Down Expand Up @@ -76,10 +73,8 @@ class Dialog extends PureComponent {
Modal.setAppElement('#root');

Dialog.defaultProps = {
disableTheme: false,
shouldCloseOnOverlayClick: true,
showCloseText: true,
theme: '',
className: '',
strings: {},
};
Expand Down
10 changes: 5 additions & 5 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
HollaEx Kit has a built in server based on express + swagger and provides API and Websocket communication for HollaEx Web or any other clients.

The main 3rd-party applications being used throughout the Server are:
- [HollaEx Tools Library](https://github.com/bitholla/hollaex-kit/tree/master/server/utils/hollaex-tools-lib)
- [HollaEx Network Library](https://github.com/bitholla/hollaex-kit/tree/master/server/utils/hollaex-network-lib)
- [HollaEx Node Library](https://github.com/bitholla/hollaex-node-lib#readme)
- [HollaEx Tools Library](https://github.com/hollaex/hollaex-kit/tree/master/server/utils/hollaex-tools-lib)
- [HollaEx Network Library](https://github.com/hollaex/hollaex-kit/tree/master/server/utils/hollaex-network-lib)
- [HollaEx Node Library](https://github.com/hollaex/hollaex-node-lib#readme)
- [Express v4.16.2](https://expressjs.com/en/api.html)
- [SwaggerUI v2.0.0](https://swagger.io/docs/specification/2-0/basic-structure/)
- [Sequelize v4.37.7](https://sequelize.org/v4/)
Expand Down Expand Up @@ -56,7 +56,7 @@ This folder holds the `swagger.yaml` file that contains all the endpoints for th
## Websocket

All websocket related files are contained in the `ws` directory. The HollaEx Kit websocket uses the following libraries:
- [HollaEx Network Library](https://github.com/bitholla/hollaex-kit/tree/master/server/utils/hollaex-network-lib) - Used to connect to the HollaEx Network Websocket
- [HollaEx Network Library](https://github.com/hollaex/hollaex-kit/tree/master/server/utils/hollaex-network-lib) - Used to connect to the HollaEx Network Websocket
- [ws](https://www.npmjs.com/package/ws) - Used to create the websocket server
- [ws-heartbeat](https://www.npmjs.com/package/ws-heartbeat) - Used to maintain websocket connection to the Network and also to disconnect any clients that don't send a message within 60 seconds

Expand All @@ -74,7 +74,7 @@ The HollaEx Kit websocket acts as a proxy between clients and the HollaEx Networ

All clients connected to the Kit will need to send a message at least once per minute or their connection will be dropped from the Kit.

For an easier way to connect to the websocket, use the [HollaEx Node Library](https://github.com/bitholla/hollaex-node-lib/blob/2.0/NETWORK_README.md#websocket).
For an easier way to connect to the websocket, use the [HollaEx Node Library](https://github.com/hollaex/hollaex-node-lib/blob/2.0/NETWORK_README.md#websocket).

### Usage

Expand Down
90 changes: 79 additions & 11 deletions server/api/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const createInitialAdmin = (req, res) => {
toolsLib.database.findOne('user', { raw: true }),
toolsLib.database.findOne('status', { raw: true })
])
.then(([ user, status ]) => {
.then(([user, status]) => {
if (status.initialized) {
throw new Error('Exchange is already initialized');
}
Expand Down Expand Up @@ -111,7 +111,7 @@ const putAdminKit = (req, res) => {
const getUsersAdmin = (req, res) => {
loggerAdmin.verbose(req.uuid, 'controllers/admin/getUsers/auth', req.auth);

const { id, search, pending, pending_type, limit, page, order_by, order, start_date, end_date, format } = req.swagger.params;
const { id, search, type, pending, pending_type, limit, page, order_by, order, start_date, end_date, format } = req.swagger.params;

if (order_by.value && typeof order_by.value !== 'string') {
loggerAdmin.error(
Expand All @@ -134,6 +134,7 @@ const getUsersAdmin = (req, res) => {
start_date: start_date.value,
end_date: end_date.value,
format: format.value,
type: type.value,
additionalHeaders: {
'x-forwarded-for': req.headers['x-forwarded-for']
}
Expand Down Expand Up @@ -322,8 +323,7 @@ const activateUser = (req, res) => {

promiseQuery
.then((user) => {
const message = `Account ${user.email} has been ${
activated ? 'activated' : 'deactivated'
const message = `Account ${user.email} has been ${activated ? 'activated' : 'deactivated'
}`;
return res.json({ message });
})
Expand Down Expand Up @@ -1205,8 +1205,8 @@ const getEmailTypes = (req, res) => {

let arrMailType = Object.keys(data['email'][LANGUAGE_DEFAULT]);
arrMailType.sort((a, b) => {
if(a < b) { return -1; }
if(a > b) { return 1; }
if (a < b) { return -1; }
if (a > b) { return 1; }
return 0;
});

Expand Down Expand Up @@ -1912,7 +1912,7 @@ const setUserBank = (req, res) => {
if (!user) {
throw new Error('User not found');
}

const existingBankAccounts = user.bank_account;

let sendEmail = false;
Expand All @@ -1938,7 +1938,7 @@ const setUserBank = (req, res) => {

if (sendEmail) {
try {
toolsLib.sendEmail('BANK_VERIFIED', updatedUser.email, { bankAccounts: updatedUser.bank_account.filter((account) => account.status === VERIFY_STATUS.COMPLETED ) }, updatedUser.settings);
toolsLib.sendEmail('BANK_VERIFIED', updatedUser.email, { bankAccounts: updatedUser.bank_account.filter((account) => account.status === VERIFY_STATUS.COMPLETED) }, updatedUser.settings);
} catch (err) {
loggerAdmin.error(req.uuid, 'controllers/admin/setUserBank err', err.message);
}
Expand Down Expand Up @@ -1967,7 +1967,7 @@ const verifyUserBank = (req, res) => {
user_id,
bank_id
);

toolsLib.user.getUserByKitId(user_id, false)
.then((user) => {
if (!user) {
Expand Down Expand Up @@ -1996,7 +1996,7 @@ const verifyUserBank = (req, res) => {
})
.then((user) => {
try {
toolsLib.sendEmail('BANK_VERIFIED', user.email, { bankAccounts: user.bank_account.filter((account) => account.status === VERIFY_STATUS.COMPLETED ) }, user.settings);
toolsLib.sendEmail('BANK_VERIFIED', user.email, { bankAccounts: user.bank_account.filter((account) => account.status === VERIFY_STATUS.COMPLETED) }, user.settings);
} catch (err) {
loggerAdmin.error(req.uuid, 'controllers/admin/verifyUserBank email catch', err.message);
}
Expand Down Expand Up @@ -2049,6 +2049,71 @@ const revokeUserBank = (req, res) => {
});
};

const generateDashToken = (req, res) => {
loggerAdmin.verbose(
req.uuid,
'controllers/admin/generateDashToken auth',
req.auth
);

toolsLib.security.generateDashToken({
additionalHeaders: {
'x-forwarded-for': req.headers['x-forwarded-for']
}
})
.then(({ token }) => {
if (!token) {
throw new Error('We could not generate the token. Please try again.');
}
return res.status(201).json({ token });
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/generateDashToken err', err.message);
return res.status(err.status || 400).json({ message: err.message });
});
};

const getUserAffiliation = (req, res) => {
loggerAdmin.debug(req.uuid, 'controllers/admin/getUserAffiliation auth', req.auth.sub);

const user_id = req.swagger.params.user_id.value;
const { limit, page, order_by, order, start_date, end_date } = req.swagger.params;


toolsLib.user.getAffiliationCount(user_id, {
limit: limit.value,
page: page.value,
order_by: order_by.value,
order: order.value,
start_date: start_date.value,
end_date: end_date.value
})
.then((data) => {
loggerAdmin.verbose(req.uuid, 'controllers/admin/getUserAffiliation count', data.count);
return res.json(data);
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/getUserAffiliation', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

const getUserReferer = (req, res) => {
loggerAdmin.debug(req.uuid, 'controllers/admin/getUserReferer auth', req.auth.sub);

const user_id = req.swagger.params.user_id.value;

toolsLib.user.getUserReferer(user_id)
.then((email) => {
loggerAdmin.verbose(req.uuid, 'controllers/admin/getUserReferer email', email);
return res.json({ email });
})
.catch((err) => {
loggerAdmin.error(req.uuid, 'controllers/admin/getUserReferer', err.message);
return res.status(err.statusCode || 400).json({ message: errorMessageConverter(err) });
});
};

module.exports = {
createInitialAdmin,
getAdminKit,
Expand Down Expand Up @@ -2099,5 +2164,8 @@ module.exports = {
getEmailTypes,
setUserBank,
verifyUserBank,
revokeUserBank
revokeUserBank,
generateDashToken,
getUserAffiliation,
getUserReferer
};
Loading

0 comments on commit e3375fe

Please sign in to comment.