Skip to content

Instantly share code, notes, and snippets.

@jthegedus
jthegedus / express-functions.js
Last active April 20, 2020 04:04
Express & Cloud Functions for Firebase example
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
// Express Servers
const {simpleServer, corsServer, cleanPathServer} = require('./server');
// HTTP Cloud Functions
const simple = functions.https.onRequest(simpleServer);
@jthegedus
jthegedus / Dockerfile
Created May 14, 2019 23:25
Berglas w Node.js
FROM node:10-alpine
RUN apk add ca-certificates
ENV NODE_ENV=production
WORKDIR /urs/src/app
COPY package.json yarn.lock ./
RUN yarn install --production
@jthegedus
jthegedus / firebase-cron-cloud-functions.js
Last active May 8, 2019 13:04
jthegedus|firebase-cron-cloud-functions
const functions = require('firebase-functions');
exports.englishSyntax = functions.pubsub
.schedule('every 10 minutes')
.timeZone('Australia/NSW')
.onRun(context => {
console.log('triggered every 10 minutes', context);
});
exports.cronSyntax = functions.pubsub
import { onNewUser } from "./onNewUser/function";
// functions in this object will be prefixed with "users"
// Eg: auth-onNewUser
const auth = { onNewUser };
export { auth };
+- dist/ # compiled code
| |
| +- index.js # CF entrypoint, defined by pkg.json "main" field
| +- index.js.map # maps compiled to raw source in ../src/
+- node_modules/ # ignored by firebase-tools on upload
+- src/ # raw source code to compile
| |
| +- index.<ext> # entrypoint to compile
+- <config file> # config file depending on the tool
+- .firebaserc # firebase project identification config
@jthegedus
jthegedus / test.re
Created April 3, 2018 15:56
Reason BS labeled default args
type options = {
.
"dir": string,
"key": string
};
let defaultOptions: options = {"dir": "conf/", "key": "configuration"};
let createConf = (~opts=defaultOptions, ()) => Js.log(opts);
@jthegedus
jthegedus / function-next.config.js
Last active April 3, 2018 12:41
next.js plugin
const nextEnv = require('next-env');
const nextEnvOpts = { ... };
module.exports = (phase, {defaultConfig}) => {
return nextEnv(nextEnvOpts, defaultConfig, phase); // explicitly pass phase
}
/// with other plugins
const withTypescript = require('@zeit/next-typescript')
@jthegedus
jthegedus / firebase-import-sizes.md
Last active January 29, 2018 01:17
Firebase JS SDK import sizes
tool package size(K) gzipped(K)
Firebase firebase 412 116
Firebase client core @firebase/app 19.4 6.27
Authentication @firebase/auth 134.81 43.42
Realtime DB @firebase/database 193.34 47.15
Cloud Messaging @firebase/messaging 19.66 5.63
Cloud Storage @firebase/storage 35.89 10.5
Total 403.1 112.97
@jthegedus
jthegedus / gist1.js
Last active June 13, 2020 04:46
Embed.ly GitHub provider cannot discern files within Gists. https://codeburst.io/github-medium-with-embedly-30d9115af585
export default () => <div>File one</div>;
@jthegedus
jthegedus / .eslintrc.yml
Last active December 16, 2017 07:57
My ESLint Config
---
root: true
# Use create-react-app eslint config as it does not apply styling rules (use prettier for styling) - https://github.com/facebookincubator/create-react-app/tree/master/packages/eslint-config-react-app
#
# yarn add eslint-config-react-app babel-eslint@^7.2.3 eslint@^4.1.1 eslint-plugin-flowtype@^2.34.1 eslint-plugin-import@^2.6.0 eslint-plugin-jsx-a11y@^5.1.1 eslint-plugin-react@^7.1.0
# yarn add eslint-plugin-import
extends:
- react-app