remove not used old mock-api
This commit is contained in:
@@ -1,136 +0,0 @@
|
||||
version: "3.7"
|
||||
|
||||
x-network: &NETWORK
|
||||
BECH32_PREFIX: nymt
|
||||
DENOM: nymt
|
||||
STAKE_DENOM: nyxt
|
||||
WASMD_VERSION: v0.27.0
|
||||
|
||||
services:
|
||||
genesis_validator:
|
||||
build:
|
||||
context: docker/validator
|
||||
args: *NETWORK
|
||||
image: validator:latest
|
||||
ports:
|
||||
- "26657:26657"
|
||||
- "1317:1317"
|
||||
container_name: genesis_validator
|
||||
volumes:
|
||||
- "genesis_volume:/genesis_volume"
|
||||
- "genesis_nyxd:/root/.nyxd"
|
||||
environment: *NETWORK
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 172.168.10.2
|
||||
command: ["genesis"]
|
||||
secondary_validator:
|
||||
build:
|
||||
context: docker/validator
|
||||
args: *NETWORK
|
||||
image: validator:latest
|
||||
ports:
|
||||
- "36657:26657"
|
||||
- "2317:1317"
|
||||
volumes:
|
||||
- "genesis_volume:/genesis_volume"
|
||||
- "secondary_nyxd:/root/.nyxd"
|
||||
environment: *NETWORK
|
||||
networks:
|
||||
localnet:
|
||||
ipv4_address: 172.168.10.3
|
||||
depends_on:
|
||||
- "genesis_validator"
|
||||
command: ["secondary"]
|
||||
# mixnet_contract:
|
||||
# build: docker/mixnet_contract
|
||||
# image: contract:latest
|
||||
# volumes:
|
||||
# - ".:/nym"
|
||||
# vesting_contract:
|
||||
# build: docker/vesting_contract
|
||||
# image: vesting_contract:latest
|
||||
# volumes:
|
||||
# - ".:/nym"
|
||||
# contract_uploader:
|
||||
# build: docker/typescript_client
|
||||
# image: contract_uploader:typescript
|
||||
# volumes:
|
||||
# - "genesis_volume:/genesis_volume:ro"
|
||||
# - "contract_volume:/contract_volume"
|
||||
# - ".:/nym"
|
||||
# depends_on:
|
||||
# - "genesis_validator"
|
||||
# - "secondary_validator"
|
||||
# - "mixnet_contract"
|
||||
# environment:
|
||||
# BECH32_PREFIX: *BECH32_PREFIX
|
||||
mnemonic_echo:
|
||||
build: docker/mnemonic_echo
|
||||
image: mnemonic_echo:latest
|
||||
volumes:
|
||||
- "genesis_volume:/genesis_volume:ro"
|
||||
depends_on:
|
||||
- "genesis_validator"
|
||||
- "secondary_validator"
|
||||
|
||||
# mongo:
|
||||
# image: mongo:latest
|
||||
# command:
|
||||
# - --storageEngine=wiredTiger
|
||||
# volumes:
|
||||
# - mongo_data:/data/db
|
||||
# block_explorer:
|
||||
# build:
|
||||
# context: https://github.com/forbole/big-dipper.git#v0.41.x-7
|
||||
# image: block_explorer:v0.41.x-7
|
||||
# ports:
|
||||
# - "3080:3000"
|
||||
# depends_on:
|
||||
# - "mongo"
|
||||
# environment:
|
||||
# ROOT_URL: ${APP_ROOT_URL:-http://localhost}
|
||||
# MONGO_URL: mongodb://mongo:27017/meteor
|
||||
# PORT: 3000
|
||||
# METEOR_SETTINGS: ${METEOR_SETTINGS}
|
||||
# explorer:
|
||||
# build:
|
||||
# context: docker/explorer
|
||||
# image: explorer:latest
|
||||
# ports:
|
||||
# - "3040:3000"
|
||||
# depends_on:
|
||||
# - "genesis_validator"
|
||||
# - "block_explorer"
|
||||
|
||||
# service to update geoip binary database, for explorer-api
|
||||
geoipupdate:
|
||||
container_name: geoipupdate
|
||||
image: maxmindinc/geoipupdate
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
GEOIPUPDATE_ACCOUNT_ID: ${GEOIPUPDATE_ACCOUNT_ID}
|
||||
GEOIPUPDATE_LICENSE_KEY: ${GEOIPUPDATE_LICENSE_KEY}
|
||||
GEOIPUPDATE_EDITION_IDS: ${GEOIPUPDATE_EDITION_IDS}
|
||||
GEOIPUPDATE_FREQUENCY: ${GEOIPUPDATE_FREQUENCY}
|
||||
networks:
|
||||
- geoipupdate
|
||||
volumes:
|
||||
- ${GEOIP_DB_DIRECTORY}:/usr/share/GeoIP
|
||||
|
||||
volumes:
|
||||
genesis_volume:
|
||||
genesis_nyxd:
|
||||
secondary_nyxd:
|
||||
|
||||
# contract_volume:
|
||||
# mongo_data:
|
||||
|
||||
networks:
|
||||
geoipupdate:
|
||||
localnet:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.168.10.0/25
|
||||
@@ -1 +0,0 @@
|
||||
NYM_API_URL=https://validator.nymtech.net
|
||||
@@ -1,4 +0,0 @@
|
||||
localhost:8001 {
|
||||
reverse_proxy 127.0.0.1:8000
|
||||
tls internal
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
# NYM API mock
|
||||
|
||||
This package provides a mock server that allows you to modify parts of the Nym API by:
|
||||
|
||||
- modifying live responses from a running Nym API
|
||||
- providing a static response
|
||||
|
||||
## How to run it?
|
||||
|
||||
Adjust the [.env](./.env) to use the Nym API you want to proxy. The defaults are for mainnet.
|
||||
|
||||
From this directory run:
|
||||
|
||||
```
|
||||
yarn
|
||||
yarn start
|
||||
```
|
||||
|
||||
When you modify files in `src` and `mocks` the process will be restarted automatically.
|
||||
|
||||
## How can I find out what methods I can override?
|
||||
|
||||
Look in the swagger docs for the Nym API, e.g. https://validator.nymtech.net/api/swagger/index.html.
|
||||
|
||||
Then write a handler to override it, for example, to return custom gateways:
|
||||
|
||||
```ts
|
||||
app.get('/api/v1/gateways', (req, res) => {
|
||||
const customGateways = JSON.parse(fs.readFileSync('./mocks/custom-gateway.json').toString());
|
||||
|
||||
// modify custom gateway
|
||||
customGateways[0].gateway.sphinx_key += '-ccc';
|
||||
customGateways[0].gateway.identity_key += '-ddd';
|
||||
|
||||
res.json(customGateways);
|
||||
});
|
||||
```
|
||||
|
||||
## How to get seed data?
|
||||
|
||||
You can get seed data from a running Nym API with:
|
||||
|
||||
```
|
||||
curl https://validator.nymtech.net/api/v1/mixnodes | jq . > mocks/mixnodes.json
|
||||
```
|
||||
|
||||
If you don't have `jq` installed, you can just do `curl https://validator.nymtech.net/api/v1/mixnodes > mocks/mixnodes.json` to store the unformatted response.
|
||||
|
||||
## HTTPS
|
||||
|
||||
If you need HTTPS then install `caddy` (see https://caddyserver.com/ or `brew install caddy` on MacOS) and run:
|
||||
|
||||
```
|
||||
yarn
|
||||
yarn start:https
|
||||
```
|
||||
|
||||
The API will available on `https://localhost:8001` e.g. https://localhost:8001/api/v1/mixnodes with a self-signed certificate.
|
||||
|
||||
Modify the [Caddyfile](Caddyfile) to set the domain for the certificate (NB: you will need to set up the DNS and control the domain records).
|
||||
|
||||
If you need the local certificate to be valid, look at https://github.com/FiloSottile/mkcert and https://dev.to/josuebustos/https-localhost-for-node-js-1p1k.
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
[
|
||||
{
|
||||
"pledge_amount": {
|
||||
"denom": "unym",
|
||||
"amount": "100000000"
|
||||
},
|
||||
"owner": "n1...",
|
||||
"block_height": 5900000,
|
||||
"gateway": {
|
||||
"host": "127.0.0.1",
|
||||
"mix_port": 1789,
|
||||
"clients_port": 9000,
|
||||
"location": "My local computer",
|
||||
"sphinx_key": "aaa",
|
||||
"identity_key": "bbb",
|
||||
"version": "1.1.11"
|
||||
},
|
||||
"proxy": null
|
||||
}
|
||||
]
|
||||
@@ -1,20 +0,0 @@
|
||||
[
|
||||
{
|
||||
"pledge_amount": {
|
||||
"denom": "unym",
|
||||
"amount": "100000000"
|
||||
},
|
||||
"owner": "n1ecaqmk4ajcc80mtgpvvqf6zun7eq8k64uz6f40",
|
||||
"block_height": 5908500,
|
||||
"gateway": {
|
||||
"host": "194.182.191.207",
|
||||
"mix_port": 1789,
|
||||
"clients_port": 9000,
|
||||
"location": "Switzerland",
|
||||
"sphinx_key": "2az9QVu6o4ZEVe72HQaxcDEdSFSxXiFvH3gWiU33Vrmn",
|
||||
"identity_key": "2BuMSfMW3zpeAjKXyKLhmY4QW1DXurrtSPEJ6CjX3SEh",
|
||||
"version": "1.1.11"
|
||||
},
|
||||
"proxy": null
|
||||
}
|
||||
]
|
||||
@@ -1,116 +0,0 @@
|
||||
[
|
||||
{
|
||||
"bond_information": {
|
||||
"mix_id": 1,
|
||||
"owner": "n1cg6lgel27zmq8yutxgnu2tdzx3hf0m8uemfpwp",
|
||||
"original_pledge": {
|
||||
"denom": "unym",
|
||||
"amount": "164186215"
|
||||
},
|
||||
"layer": 2,
|
||||
"mix_node": {
|
||||
"host": "116.203.115.86",
|
||||
"mix_port": 1789,
|
||||
"verloc_port": 1790,
|
||||
"http_api_port": 8000,
|
||||
"sphinx_key": "82MfLZ4NtBmuZXL45XC1x9HNwsK3HqW7iNNpd4YdgTdY",
|
||||
"identity_key": "12Vbu59dESdcQEfPKvbqt3r6XAhvn5xAiLB3Ke4L42Nn",
|
||||
"version": "1.1.4"
|
||||
},
|
||||
"proxy": null,
|
||||
"bonding_height": 2622578,
|
||||
"is_unbonding": false
|
||||
},
|
||||
"rewarding_details": {
|
||||
"cost_params": {
|
||||
"profit_margin_percent": "0.05",
|
||||
"interval_operating_cost": {
|
||||
"denom": "unym",
|
||||
"amount": "40000000"
|
||||
}
|
||||
},
|
||||
"operator": "177630956.71827075154157932",
|
||||
"delegates": "2002077254.831772380804187632",
|
||||
"total_unit_reward": "923810.444666272288950945",
|
||||
"unit_delegation": "1000000000",
|
||||
"last_rewarded_epoch": 2580,
|
||||
"unique_delegations": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"bond_information": {
|
||||
"mix_id": 2,
|
||||
"owner": "n1vfdtzh9vzaaxxv9n9w4ywdzle9m2pejhx0d5r7",
|
||||
"original_pledge": {
|
||||
"denom": "unym",
|
||||
"amount": "1691956412"
|
||||
},
|
||||
"layer": 1,
|
||||
"mix_node": {
|
||||
"host": "95.179.226.75",
|
||||
"mix_port": 1789,
|
||||
"verloc_port": 1790,
|
||||
"http_api_port": 8000,
|
||||
"sphinx_key": "HomUqYe7hyC1cBNbMUKWguLfq7aFdoxoQDyQsa2fGQa1",
|
||||
"identity_key": "14Qzy15U7uA8pVwvs66MuRvABSEK5C62JaDYD18WbkN7",
|
||||
"version": "1.1.10"
|
||||
},
|
||||
"proxy": null,
|
||||
"bonding_height": 2944467,
|
||||
"is_unbonding": false
|
||||
},
|
||||
"rewarding_details": {
|
||||
"cost_params": {
|
||||
"profit_margin_percent": "0.05",
|
||||
"interval_operating_cost": {
|
||||
"denom": "unym",
|
||||
"amount": "500000000"
|
||||
}
|
||||
},
|
||||
"operator": "1774161955.223791723839539477",
|
||||
"delegates": "637943739106.672292940395867727",
|
||||
"total_unit_reward": "67206510.581661315274414946",
|
||||
"unit_delegation": "1000000000",
|
||||
"last_rewarded_epoch": 2583,
|
||||
"unique_delegations": 31
|
||||
}
|
||||
},
|
||||
{
|
||||
"bond_information": {
|
||||
"mix_id": 5,
|
||||
"owner": "n1v7nrjw6pnkrdxmmuk7pjtxrzrxrtztgh33pszu",
|
||||
"original_pledge": {
|
||||
"denom": "unym",
|
||||
"amount": "28752403445"
|
||||
},
|
||||
"layer": 3,
|
||||
"mix_node": {
|
||||
"host": "194.163.191.29",
|
||||
"mix_port": 1789,
|
||||
"verloc_port": 1790,
|
||||
"http_api_port": 8000,
|
||||
"sphinx_key": "2BjwQw2txBofh7QvRAt3d8mUDLZHZgwTm3cuxpkngiWX",
|
||||
"identity_key": "26WHDRFM5QU7whg1hnxKk4iVY7DnXyZknPcNMitX6GXp",
|
||||
"version": "1.1.10"
|
||||
},
|
||||
"proxy": null,
|
||||
"bonding_height": 2935258,
|
||||
"is_unbonding": false
|
||||
},
|
||||
"rewarding_details": {
|
||||
"cost_params": {
|
||||
"profit_margin_percent": "0.05",
|
||||
"interval_operating_cost": {
|
||||
"denom": "unym",
|
||||
"amount": "40000000"
|
||||
}
|
||||
},
|
||||
"operator": "31540882828.329440044410277309",
|
||||
"delegates": "700258477245.036486032804830664",
|
||||
"total_unit_reward": "73511253.913602285045142911",
|
||||
"unit_delegation": "1000000000",
|
||||
"last_rewarded_epoch": 2583,
|
||||
"unique_delegations": 126
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "mock-nym-api",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"dotenv": "^16.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.17.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
||||
"@typescript-eslint/parser": "^5.13.0",
|
||||
"babel-loader": "^8.2.3",
|
||||
"babel-plugin-root-import": "^5.1.0",
|
||||
"eslint": "^8.10.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-typescript": "^16.1.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-import-resolver-root-import": "^1.0.4",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-jest": "^26.1.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.5.1",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-react": "^7.29.2",
|
||||
"eslint-plugin-react-hooks": "^4.3.0",
|
||||
"eslint-plugin-storybook": "^0.5.12",
|
||||
"jest": "^27.1.0",
|
||||
"prettier": "^2.8.7",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^4.6.2",
|
||||
"ts-node": "10",
|
||||
"nodemon": "^2.0.21",
|
||||
"npm-run-all": "^4.1.5"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"start": "nodemon --watch src --watch mocks -e ts,json --exec 'ts-node --esm' src/index.ts",
|
||||
"start:https": "run-p start run:caddy",
|
||||
"run:caddy": "caddy run",
|
||||
"build": "tsc --noEmit false",
|
||||
"watch": "tsc --noEmit false -w",
|
||||
"lint": "eslint src",
|
||||
"lint:fix": "eslint src --fix"
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||
import fs from 'fs';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 8000;
|
||||
|
||||
const { NYM_API_URL } = process.env;
|
||||
|
||||
if (!NYM_API_URL || NYM_API_URL.trim().length < 1) {
|
||||
throw new Error('Please specify a valid NYM_API_URL in `.env` or as an environment variable');
|
||||
}
|
||||
|
||||
// proxy the Nym API and only override some routes
|
||||
const proxy = createProxyMiddleware(['/api/**', '/swagger/**'], {
|
||||
target: NYM_API_URL,
|
||||
changeOrigin: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* Return a single custom gateway, from a static file and modify some the fields
|
||||
*/
|
||||
app.get('/api/v1/gateways', (req, res) => {
|
||||
const customGateways = JSON.parse(fs.readFileSync('./mocks/custom-gateway.json').toString());
|
||||
|
||||
// modify custom gateway
|
||||
customGateways[0].gateway.sphinx_key += '-ccc';
|
||||
customGateways[0].gateway.identity_key += '-ddd';
|
||||
|
||||
res.json(customGateways);
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns only 3 mixnodes from a static file
|
||||
*/
|
||||
app.get('/api/v1/mixnodes', (req, res) => {
|
||||
const customMixnodes = JSON.parse(fs.readFileSync('./mocks/mixnodes.json').toString());
|
||||
res.json(customMixnodes);
|
||||
});
|
||||
|
||||
// start the Express server
|
||||
app.use(proxy);
|
||||
app.listen(port, () => {
|
||||
console.log(`[API] Nym API mock is running at http://localhost:${port} and proxying ${NYM_API_URL}`);
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user