-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from eexit/fb
Host as a Firebase function
- Loading branch information
Showing
10 changed files
with
1,052 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"projects": { | ||
"default": "mirror-http-server" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
node_modules | ||
package-lock.json | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
firebase-debug.log* | ||
firebase-debug.*.log* | ||
|
||
# Firebase cache | ||
.firebase/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
FROM node:lts-alpine | ||
RUN apk add --no-cache yarn | ||
WORKDIR /app | ||
COPY . . | ||
COPY functions . | ||
RUN yarn --frozen-lockfile --loglevel=error --prod | ||
EXPOSE 8080 | ||
CMD [ "yarn", "start" ] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"functions": { | ||
"source": "functions" | ||
}, | ||
"hosting": { | ||
"public": "public", | ||
"ignore": [ | ||
"firebase.json", | ||
"**/.*", | ||
"**/node_modules/**" | ||
], | ||
"rewrites": [ | ||
{ | ||
"source": "**", | ||
"function": "mirror" | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
const mirror = require('./mirror'), | ||
functions = require('firebase-functions'); | ||
|
||
module.exports = { mirror: functions.https.onRequest(mirror.app) }; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
{ | ||
"name": "mirror-http-server", | ||
"version": "2.0.0", | ||
"description": "A dummy HTTP server that responds whatever you told it to", | ||
"scripts": { | ||
"start": "node server.js | npm run bunyan", | ||
"start:dev": "nodemon server.js | npm run bunyan", | ||
"test": "echo \"No test specified yet\"", | ||
"bunyan": "$(npm bin)/bunyan" | ||
"bunyan": "$(npm bin)/bunyan", | ||
"serve": "firebase emulators:start --only functions", | ||
"shell": "firebase functions:shell", | ||
"deploy": "firebase deploy --only functions", | ||
"logs": "firebase functions:log" | ||
}, | ||
"keywords": [ | ||
"node", | ||
|
@@ -21,11 +24,16 @@ | |
], | ||
"author": "Joris Berthelot <[email protected]>", | ||
"license": "MIT", | ||
"engines": { | ||
"node": "16" | ||
}, | ||
"dependencies": { | ||
"body-parser": "^1.20.0", | ||
"bunyan": "^1.8.15", | ||
"express": "^4.18", | ||
"lodash": ">=4.17.21" | ||
"lodash": ">=4.17.21", | ||
"firebase-admin": "^10.0.2", | ||
"firebase-functions": "^3.18.0" | ||
}, | ||
"devDependencies": { | ||
"nodemon": "^2.0.0" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
const mirror = require('./mirror'), | ||
host = '0.0.0.0', | ||
port = 8080; | ||
|
||
mirror.app.listen( | ||
port, host, 511, | ||
() => mirror.logger.info('Listening on http://%s:%s', host, port) | ||
); |
Oops, something went wrong.