Created
August 12, 2017 20:05
-
-
Save nhathiwala/6457c0fe1cb3f08f41832723ddf125e6 to your computer and use it in GitHub Desktop.
firefunctions/src/index.ts
This file contains hidden or 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
| /* | |
| * FILE NAME: index.ts | |
| * FILE PATH: './' | |
| * AUTHOR: NAYAN HATHIWALA | |
| * CREATED ON: 10/8/2017 | |
| * DESCRIPTION: MAIN INDEX. | |
| */ | |
| import * as functions from 'firebase-functions' | |
| import * as admin from 'firebase-admin' | |
| import * as express from 'express' | |
| import * as cors from 'cors' | |
| import * as bodyParser from 'body-parser' | |
| import * as cookieParser from 'cookie-parser' | |
| import * as fs from 'fs' | |
| import * as http from 'http' | |
| import * as https from 'https' | |
| import { ApiBase } from './api' | |
| import { makeUppercase } from './triggers' | |
| // FIREBASE FUNCTION INITIALIZATION | |
| admin.initializeApp(functions.config().firebase) | |
| /* | |
| * CREATING EXPRESS APP | |
| */ | |
| const app = express() | |
| app.use(cors({ origin: true })) | |
| app.use(cookieParser()) | |
| app.use(bodyParser.json()) | |
| app.use(bodyParser.urlencoded({ extended: true })) | |
| app.use("/", ApiBase) | |
| /* | |
| * EXPORTING EXPRESS APP | |
| */ | |
| export const api = functions.https.onRequest((req, res) => { | |
| if (!req.path) req.url = `/${req.url}` // prepend '/' to keep query params if any | |
| return app(req, res) | |
| }) | |
| /* | |
| * EXPORTING EVENT TRIGGERS HERE | |
| */ | |
| export { makeUppercase } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment