first commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -0,0 +1,37 @@
|
||||
# Crypto Assets Monitor (Backend)
|
||||
|
||||
## Download
|
||||
|
||||
```bash
|
||||
git clone https://github.com/vaidis/Crypto-Assets-Monitor.git
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
cd CryptoAssets-Monitor/Back
|
||||
npm install
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
```bash
|
||||
GET /kraken/assets
|
||||
GET /kraken/assetpairs?asset=BTC
|
||||
GET /kraken/ohlc?pair=XXBTCUSDT&interval=60
|
||||
```
|
||||
|
||||
## Test Endpoints
|
||||
```bash
|
||||
curl --location --request GET 'http://localhost:8080/kraken/assets'
|
||||
curl --location --request GET 'http://localhost:8080/kraken/assetpairs?asset=XBT'
|
||||
curl --location --request GET 'http://localhost:8080/kraken/ohlc?pair=XXBTZEUR&interval=60'
|
||||
```
|
||||
|
||||
or import the [postman_collection.json](./postman_collection.json) to postman rest api client
|
||||
@@ -0,0 +1,7 @@
|
||||
const app = require('./src/app');
|
||||
const config = require('./src/config')
|
||||
|
||||
var server = app.listen(config.app.port, function () {
|
||||
var port = server.address().port
|
||||
console.log("Candlestick api listening at http://localhost:%s", port)
|
||||
})
|
||||
Generated
+1550
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "candlestick-app-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "Candlestick REST API with node js.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/anantkolvankar/candlestick-app-backend.git"
|
||||
},
|
||||
"author": "anantkolvankar",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/anantkolvankar/candlestick-app-backend/issues"
|
||||
},
|
||||
"homepage": "https://github.com/anantkolvankar/candlestick-app-backend#readme",
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"request": "^2.88.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
var http = require("http");
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
next();
|
||||
});
|
||||
|
||||
var ApplicationController = require('./application_controller');
|
||||
app.use('', ApplicationController);
|
||||
module.exports = app;
|
||||
@@ -0,0 +1,26 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const api_helper = require('./thirdparty_api')
|
||||
const config = require('./config');
|
||||
|
||||
|
||||
|
||||
router.get('/coins/markets', function (req, res) {
|
||||
// let pair = req.query.pair;
|
||||
// let interval = req.query.interval;
|
||||
|
||||
let url = config.coingecko.api_url + '/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=false';
|
||||
|
||||
api_helper.REMOTE_API_call(url)
|
||||
.then(response => {
|
||||
console.log("url: ", url);
|
||||
console.log("response: ", response);
|
||||
res.json(response);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("error: ", error);
|
||||
res.send(error);
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,10 @@
|
||||
const config = {
|
||||
app: {
|
||||
port: 8080
|
||||
},
|
||||
coingecko: {
|
||||
api_url: 'https://api.coingecko.com/api/v3'
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -0,0 +1,12 @@
|
||||
const request = require('request')
|
||||
|
||||
module.exports = {
|
||||
REMOTE_API_call : function(url){
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, { json: true }, (err, res, body) => {
|
||||
if (err) reject(err)
|
||||
resolve(body)
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user