feat: initial commit copied from git@github.com:dancesWithCycles/protobufjs-playground.git
This commit is contained in:
commit
fbd80998d0
|
@ -0,0 +1,4 @@
|
||||||
|
NODE_ENV=development
|
||||||
|
URL=https://api.goswift.ly/real-time/rtamaryland/gtfs-rt-vehicle-positions
|
||||||
|
TOKEN=d404373607b6b6edc72fff62d06373ca
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
require('dotenv').config();
|
||||||
|
const axios = require('axios');
|
||||||
|
const debug=require('debug')('axios');
|
||||||
|
|
||||||
|
const URL=process.env.URL||'https://dedriver.org/gtfs/realtime';
|
||||||
|
debug('URL: '+URL)
|
||||||
|
|
||||||
|
const TOKEN=process.env.TOKEN||'TOKEN';
|
||||||
|
debug('TOKEN: '+TOKEN)
|
||||||
|
|
||||||
|
run().catch(err => {
|
||||||
|
debug('run: error')
|
||||||
|
console.log(err)
|
||||||
|
});
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
debug('run:...')
|
||||||
|
|
||||||
|
|
||||||
|
//HTTP GET
|
||||||
|
let dataGet = await axios.get(
|
||||||
|
//'https://dedriver.org/gtfs/realtime',
|
||||||
|
URL,
|
||||||
|
//'http://67.212.79.244:8080/hermes_st_Transcollines/pb/vehiclePositions.pb',
|
||||||
|
//'https://dedriver.org/gtfs-rt/vehiclePostions.pb',
|
||||||
|
//'http://localhost:3000/user',
|
||||||
|
{
|
||||||
|
headers:{
|
||||||
|
'accept':'application/octet-stream',
|
||||||
|
'authorization':`${TOKEN}`
|
||||||
|
//'authorization':`Basic ${TOKEN}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(res => res.data);
|
||||||
|
debug('data received via GET');
|
||||||
|
debug('dataGet len: %s',dataGet.length)
|
||||||
|
|
||||||
|
/*
|
||||||
|
//HTTP POST
|
||||||
|
|
||||||
|
//url as first,
|
||||||
|
//request body as second and
|
||||||
|
//options as third POST argument
|
||||||
|
//response is returned
|
||||||
|
const res=await axios.post(
|
||||||
|
'http://localhost:3000/user',
|
||||||
|
//'https://dedriver.org/gtfs/realtime',
|
||||||
|
encodedPost,
|
||||||
|
{
|
||||||
|
headers:{
|
||||||
|
'content-type':'application/octet-stream'}
|
||||||
|
// 'content-type':'application/x-protobuf'}
|
||||||
|
//'transformRequest':[]
|
||||||
|
}
|
||||||
|
).then(res => res.data);
|
||||||
|
debug('POST sent');
|
||||||
|
debug('res JSON: %s',JSON.stringify(res));
|
||||||
|
//debug('res content-type: %s',res.data.headers['content-type']);
|
||||||
|
*/
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "axios",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Stefan Begerad",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^2.0.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.21.1",
|
||||||
|
"dotenv": "^8.2.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue