-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
29 lines (23 loc) · 854 Bytes
/
index.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
var express = require("express");
const fetch = require('node-fetch');
const { addToWall } = require('./utils');
var app = express();
// Post a quote to the Zen wall
// The API base URL is retrieved from the BASE_URL environment variable
// The GitHub repository URL is passed in as a query parameter
app.get("/addtowall", async (req, res, next) => {
try {
const baseUrl = process.env.BASE_URL;
const repoUrl = req.query.repoUrl;
console.log(`Base URL: ${baseUrl}`);
console.log(`Repo URL: ${repoUrl}`);
let response = await addToWall(baseUrl, repoUrl);
console.log('Got zen');
res.json(response);
} catch (error) {
res.status(500).send(error);
};
});
app.listen(process.env.PORT || 3000, () => {
console.log(`Server running on port ${process.env.PORT || 3000}`);
});