Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create edge-monitor-server and test info/login endpoints #2

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib/
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": [
"standard-kit/prettier",
"standard-kit/prettier/typescript",
"standard-kit/prettier/node"
],
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": [
"simple-import-sort"
],
"rules": {
"simple-import-sort/imports": "error"
},
"root": true
}
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

- [ ] Yes
- [ ] No

### Dependencies

<!-- Replace line with PRs which this PR depends if any --> none

### Description

<!-- Describe your changes textually and/or pictorially if necessary --> none
20 changes: 20 additions & 0 deletions .github/workflows/monitor-server-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: edge-monitor-server CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn prepare
- run: yarn verify
9 changes: 9 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: PR Checks
on: [pull_request]
jobs:
block-wip-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Block WIP PR
uses: samholmes/[email protected]
28 changes: 28 additions & 0 deletions .github/workflows/pr-rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/autosquash') ||
contains(github.event.comment.body, '/fixup') ||
contains(github.event.comment.body, '/rebase')
)
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: EdgeApp/rebase@changelog-resolver
with:
autosquash: ${{ true }}
changelogResolver: ${{ true }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/lib/
/config.json
/node_modules/
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "indexEngine",
"args": [
"-r",
"sucrase/register",
"${workspaceFolder}/src/indexEngine.ts"
]
},
{
"type": "node",
"request": "launch",
"name": "indexApi",
"args": [
"-r",
"sucrase/register",
"${workspaceFolder}/src/indexApi.ts"
]
},
]
}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-scripts true
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# edge-monitor-server

## Unreleased
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Released under MIT License

Copyright (c) 2023 Airbitz Inc (dba Edge)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# edge-monitor-server

This server monitors various infrasture utilized by the Edge platform.

## Setup

Run `yarn` then edit the `config.json` created

`yarn start` to start the monitoring engines

### Manage server using `pm2`

First, install pm2 to run at startup:

```sh
yarn global add pm2
pm2 startup # Then do what it says
```

Next, tell pm2 how to run the server script:

```sh
# install:
pm2 start pm2.json
pm2 save

# check status:
pm2 monit
tail -f /var/log/pm2/monitorEngine.log

# manage:
pm2 restart monitorEngine
pm2 reload monitorEngine
pm2 stop monitorEngine
```

### Updating

To update the code running on the production server, use the following procedure:

```sh
git pull
yarn
yarn prepare
pm2 restart all
```

Each deployment should come with its own version bump, changelog update, and git tag.
35 changes: 35 additions & 0 deletions fixtures/infoServer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
swansontec marked this conversation as resolved.
Show resolved Hide resolved
"_id": "infoServer",
"pluginId": "fetchPlugin",
"runFrequencyMins": 15,
"data": {
"clusters": [
{
"servers": [
"https://info1.edge.app",
"https://info2.edge.app",
"https://info-us1.edge.app",
"https://info-eu1.edge.app"
],
"apiCalls": [
{
"method": "GET",
"path": "/v1/exchangeInfo/edge",
"expectThrow": false,
"headers": {},
"body": null,
"result": {
"buy": {
"disablePlugins": {
"creditcard": {
"myProviderId": true
}
}
}
}
}
]
}
]
}
}
108 changes: 108 additions & 0 deletions fixtures/loginServer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"_id": "loginServer",
"pluginId": "fetchPlugin",
"runFrequencyMins": 15,
"data": {
"clusters": [
{
"servers": [
"https://login.edge.app",
"https://login1.edge.app",
"https://login2.edge.app"
],
"apiCalls": [
{
"testName": "Password Login",
"method": "POST",
"path": "/api/v2/login",
"expectThrow": false,
"headers": {
"Authorization": "Token {{EDGE_API_KEY}}"
},
"body": {
"userId": "xxx",
"passwordAuth": "xxx"
},
"result": {
"results": {
"appId": "",
"created": "xxx",
"loginId": "xxx",
"syncToken": "xxx",
"passwordAuthBox": {
"encryptionType": 0,
"data_base64": "xxx",
"iv_hex": "xxx"
}
}
}
},
{
"testName": "PIN2 Login",
"method": "POST",
"path": "/api/v2/login",
"expectThrow": false,
"headers": {
"Authorization": "Token {{EDGE_API_KEY}}"
},
"body": {
"pin2Id": "xxx",
"pin2Auth": "xxx"
},
"result": {
"results": {
"appId": "",
"created": "xxx",
"loginId": "xxx",
"syncToken": "xxx",
"passwordAuthBox": {
"encryptionType": 0,
"data_base64": "xxx",
"iv_hex": "xxx"
}
}
}
},
{
"testName": "User ID Exists",
"method": "POST",
"path": "/api/v2/login",
"expectThrow": false,
"headers": {
"Authorization": "Token {{EDGE_API_KEY}}"
},
"body": {
"userId": "xxx"
},
"result": {
"results": {
"loginId": "xxx",
"passwordAuthSnrp": {
"salt_hex": "xxx",
"n": 16384,
"r": 1,
"p": 1
}
},
"status_code": 0,
"message": "Success"
}
},
{
"testName": "User ID Available",
"method": "POST",
"path": "/api/v2/login",
"expectThrow": true,
"headers": {
"Authorization": "Token {{EDGE_API_KEY}}"
},
"body": {
"userId": "xxx"
},
"result": {}
}
]
}
]
}
}
Loading
Loading