{"size": 1285, "ext": "js", "max_stars_repo_path": "functions/lib/index.js", "max_stars_repo_name": "UnJavaScripter/devcast", "max_stars_repo_stars_event_min_datetime": "2018-08-15T22:14:48.000Z", "max_stars_repo_stars_event_max_datetime": "2018-08-15T22:14:48.000Z", "max_issues_repo_path": "functions/lib/index.js", "max_issues_repo_name": "UnJavaScripter/devcast", "max_issues_repo_issues_event_min_datetime": "2018-08-02T02:59:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T02:45:41.000Z", "max_forks_repo_path": "functions/lib/index.js", "max_forks_repo_name": "UnJavaScripter/devcast", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 42.8333333333, "max_line_length": 159, "alphanum_fraction": 0.6661478599}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const functions = require("firebase-functions");
const admin = require('firebase-admin');
admin.initializeApp();
const express = require('express');
const exphbs = require('express-handlebars');
const app = express();
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
app.get('/', (req, res) => {
    const episodesRef = admin.firestore().collection('episodes');
    res.set('Cache-Control', 'public, max-age=300, s-maxage=600');
    return episodesRef
        .get()
        .then(querySnapshot => {
        const data = querySnapshot.docs.map(documentSnapshot => documentSnapshot.data()).sort((a, b) => a.release_id > b.release_id);
        return res.render('home', { episodes: data });
    })
        .catch(err => {
        return res.render('home', { episodes: [] });
    });
});
app.get('/episodes/:episodeId', (req, res) => {
    const episodeId = req.params.episodeId;
    const publicToken = req.query.t;
    res.redirect(`https://firebasestorage.googleapis.com/v0/b/devcast-7b66e.appspot.com/o/episodes%2Fdevcast-${episodeId}.mp3?alt=media&token=${publicToken}`);
});
exports.main = functions.https.onRequest(app);
//# sourceMappingURL=index.js.map