Last active
May 3, 2020 02:37
-
-
Save Chamuth/d9cee3cde9850e7c24280a43123a8f7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
const express = require("express"); | |
const path = require('path'); | |
const bodyParser = require('body-parser'); | |
const admin = require("firebase-admin"); | |
var serviceAccount = require("./serviceAccountKey.json"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount), | |
databaseURL: "https://vlearn-lanka.firebaseio.com", | |
storageBucket: "vlearn-lanka.appspot.com" | |
}); | |
var db = admin.firestore(); | |
var bucket = admin.storage().bucket(); | |
const orgMiddleware = require("./middleware/orgMiddleware.js"); | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
app.set('view engine', 'ejs'); | |
app.set('views', path.join(__dirname, '../views')); | |
// Storage API | |
var api = require("./api/api.js"); | |
api.api(app, db, bucket); | |
// Landing pages and promotional stuff | |
app.get("/", (req, res) => | |
{ | |
bucket.getFiles({directory: "/organizations/qsqL7rxYbQSaEyO37edZ/shared/2FiakID2Ywcq2CK3e6aN"}, (err, files, next, response) => | |
{ | |
res.json(files); | |
}); | |
// res.render("pages/index"); | |
}); | |
// Web Application | |
app.get("/:org/", (req,res) => | |
{ | |
res.json("GOOD"); | |
}); | |
var _app = functions.https.onRequest(app); | |
module.exports = { | |
_app | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment