Skip to content

Instantly share code, notes, and snippets.

View jthegedus's full-sized avatar
👨‍💻

James Hegedus jthegedus

👨‍💻
View GitHub Profile
@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);
+- 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
import { onNewUser } from "./onNewUser/function";
// functions in this object will be prefixed with "users"
// Eg: auth-onNewUser
const auth = { onNewUser };
export { auth };
@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
@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 / 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 / graphql-functions.js
Last active March 16, 2021 09:48
GraphQL & Cloud Functions for Firebase example
import {https} from 'firebase-functions';
import gqlServer from './graphql/server';
const server = gqlServer();
// Graphql api
// https://us-central1-<project-name>.cloudfunctions.net/api/
const api = https.onRequest(server);
export {api};
@jthegedus
jthegedus / function.js
Created May 26, 2019 06:50
Cloud Run web server and dependencies example
exports.helloWorld = (req, res) => {
res.send('Hello, World');
};
@jthegedus
jthegedus / server.js
Last active May 25, 2020 03:09
Next.js on Cloud Functions for Firebase
const admin = require("firebase-admin");
const functions = require("firebase-functions");
const next = require("next");
const config = require("./next.config");
admin.initializeApp();
const dev = process.env.NODE_ENV !== "production";
const app = next({
dev,
@jthegedus
jthegedus / sitemap
Created May 25, 2020 03:01
github.com/jthegedus/firebase-gcp-examples/tree/master/functions-nextjs
┌ ○ / <-- static
├ ○ /404 <-- static
├ ● /about <-- SSG page
├ λ /blog <-- SSR page
├ ● /blog/[pid] <-- SSG dynamic route with fallback:true
└ ○ /blog/not-a-post <-- static
+ First Load JS shared by all
├ static/pages/_app.js
├ chunks/commons.some_uid.js
├ chunks/framework.some_uid.js