-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
49 lines (43 loc) · 983 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// app.js
//
// Aternity Tech-Community
// 107-opentelemetry-autoinstrumentation-nodejs-app
// version: 22.4.1
//
// Demo app in Nodejs
//
// Usage
//
// - run the service
//
// node app.js
//
// - test from a client
//
// curl http://localhost
//
// curl http://localhost/fetch
'use strict';
const PORT = process.env.PORT || '80';
const express = require('express');
const axios = require('axios');
const app = express();
app.get('/fetch', (req, res) => {
var response = axios.get("https://github.com/Aternity")
.then(function (response) {
console.log("success");
console.log(response);
res.send('success');
})
.catch(function (error) {
console.log("error");
console.log(error);
res.send('error');
});
});
app.get('/', (req, res) => {
res.send('ready');
});
app.listen(parseInt(PORT, 10), () => {
console.log(`Listening for requests on http://localhost:${PORT}`);
});