Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔒 Support state in oauth login, add configs, and fix some minor bugs #6

Merged
merged 11 commits into from
Mar 8, 2019
90 changes: 5 additions & 85 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,86 +1,6 @@
.DS_Store

# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE
.idea

# Service worker
sw.*
node_modules
functions/nuxt
functions/dist/
functions/nuxt.config.js
public
29 changes: 29 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"functions": {
"source": "functions/dist",
"predeploy": [
"npm --prefix src run lint && npm --prefix src run build && rm -rf functions/nuxt && cp -r src/.nuxt/ functions/nuxt/ && cp src/nuxt.config.js functions/ && npm --prefix functions run lint && npm --prefix functions run package "
]
},
"hosting": {
"predeploy": [
"rm -rf public/* && mkdir -p public/_nuxt && cp -r src/.nuxt/dist/client public/_nuxt && cp -a src/static/. public/ && cp -a public_base/. public/"
],
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/api/**",
"function": "apiHttp"
},
{
"source": "**",
"function": "ssrapp"
}
]
}
}
20 changes: 20 additions & 0 deletions functions/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": "8.11.1"
}
}
]
],
"env": {
"production": {
"presets": ["minify"]
}
},
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
4 changes: 4 additions & 0 deletions functions/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"parser": "babel-eslint",
"extends": ["airbnb-base", "plugin:prettier/recommended"]
}
5 changes: 5 additions & 0 deletions functions/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"singleQuote": true,
"bracketSpacing": true,
}
1 change: 1 addition & 0 deletions functions/apiHttp/api
13 changes: 13 additions & 0 deletions functions/apiHttp/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const functions = require('firebase-functions');

const config = {};

config.IS_TESTNET = functions.config().constant.network === 'rinkeby';
if (config.IS_TESTNET) process.env.IS_TESTNET = 'TRUE';
config.FIRESTORE_USER_ROOT = functions.config().db.FIRESTORE_USER_ROOT;
config.LIKE_CO_CLIENT_ID = functions.config().likeco_oauth.clientid;
config.LIKE_CO_CLIENT_SECRET = functions.config().likeco_oauth.secret;
config.COOKIE_SECRET = functions.config().cookie.secret;
config.EXTERNAL_URL = functions.config().constant.external_url;

module.exports = config;
19 changes: 19 additions & 0 deletions functions/apiHttp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const functions = require('firebase-functions');
const express = require('express');
const helmet = require('helmet');

const api = require('./api');

const app = express();

app.use(helmet());
app.set('trust proxy', 1);
app.use('/api', api);

if ((functions.config().constant || {}).external_url) {
process.env.API_URL = functions.config().constant.external_url;
}

const internalHttp = functions.https.onRequest(app);

module.exports = internalHttp;
9 changes: 9 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable global-require */

if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'ssrapp') {
exports.ssrapp = require('./ssrapp');
}

if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'apiHttp') {
exports.apiHttp = require('./apiHttp');
}
Loading