-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (27 loc) · 909 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
30
31
32
33
34
35
36
37
require('dotenv').config();
const express = require('express');
const app = express();
const ejs = require('ejs');
const axios = require('axios');
const fbPoster = require('./services/facebookPost.service');
const screenshotService = require("./services/apodScreenshotService");
const APOD_API_KEY = process.env.APOD_API_KEY;
const FLASH_API_KEY = process.env.FLASH_API_KEY;
app.set('views', './views');
app.set('view engine', 'ejs');
app.listen(process.env.PORT);
app.get('/apod', (req, res) => {
axios.get(`https://api.nasa.gov/planetary/apod?api_key=${APOD_API_KEY}`)
.then(data => {
res.render('apod.ejs', { data });
})
})
app.get('/fb-publish', async (req, res) => {
const data = {
message: "APOD",
url: await screenshotService.getScreenshot()
}
fbPoster.makePost(data);
res.send(200)
})
app.use(express.static("./static/"));