Skip to content

Instantly share code, notes, and snippets.

@evdama
evdama / firebase.json
Created July 11, 2019 09:46
caching for static contents using firebase headers
{
"functions": {
"predeploy": [
"node predeploy.js"
],
"source": "functions"
},
"firestore": {
"rules": "config/firestore.rules",
"indexes": "config/firestore.indexes.json"
@evdama
evdama / tsconfig.json
Last active July 13, 2019 02:26
ts config for firebase cloud functions (used in a sapper project)
{
"compilerOptions": {
"allowJs": true,
"alwaysStrict": true,
"checkJs": true,
"module": "commonjs",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
@evdama
evdama / package.json
Created July 13, 2019 05:38
script section, invoke with npm run-s edm:*
{
"name": "",
"description": "This is the source code repository for Foo",
"version": "0.0.1",
"license": "UNLICENSED",
"scripts": {
"edm:purge": "rm -rf __sapper__/ node_modules/ package-lock.json static/global.css yarn.lock src/node_modules/@sapper functions/__sapper__ functions/node_modules/ functions/package-lock.json functions/src/node_modules functions/yarn.lock ",
"edm:backup": "cp -a ../edm ../edm_$(date +%s)",
"edm:install": "npm install; cd functions; npm install",
"edm:build": "sapper build; cd functions; tsc; cd ..; node predeploy.js",
@evdama
evdama / predeploy.js
Created July 13, 2019 05:39
used to copy/move the build __sapper__ folder into functions directory
const fs = require('fs-extra');
fs.remove('./functions/__sapper__').then(() => {
console.log('copying build folder to functions')
fs.copySync('./__sapper__', './functions/__sapper__');
});
@evdama
evdama / package.json
Created July 14, 2019 02:19
sapper, firebase, tailwind, typescript ... functions/package.json
{
"name": "functions",
"scripts": {
"build": "tsc",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"serve": "firebase serve --only functions,hosting",
"shell": "firebase functions:shell",
"start": "npm run shell"
},
@evdama
evdama / tailwind.css
Created July 14, 2019 02:29
src/css/tailwind.css .... that is the standard tailwind starter... change as needed
@import "tailwindcss/base";
@import "tailwindcss/components";
@import './components';
@import "tailwindcss/utilities";
@evdama
evdama / tailwind.config.js
Created July 14, 2019 02:30
standard tw config inside root folder... change as desired
const colors = {
'primary-blue': '#0e2730'
};
module.exports = {
theme: {
container: {
center: true,
padding: '2rem',
},
@evdama
evdama / .gitignore
Created July 14, 2019 02:32
inside project root
# .firebaserc https://stackoverflow.com/questions/43527359/what-is-the-practice-on-committing-firebase-files-in-a-nodejs-app
# src/firebase/config.js this one is public information as it needs to be available on the client to identify the firebase project at hand
**/__sapper__
.DS_Store
.firebase/
firebase-debug.log
static/global.css
yarn-error.log
src/node_modules/*
!src/node_modules/utils
@evdama
evdama / index.ts
Created July 14, 2019 03:00
usage of underscore prepend for unused paramter and compiler option "noUnusedParameters": true
// TODO: replace type any for request and response
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
// https://github.com/firebase/functions-samples/tree/master/typescript-getting-started
// https://stackoverflow.com/questions/41685054/clarification-on-typescripts-nounusedparameters-compiler-option
import * as functions from 'firebase-functions';
// We have to import the built version of the server middleware.
const { app } = require('../__sapper__/build/server/server');
@evdama
evdama / tailwind.config.js
Created July 15, 2019 04:32
with new google fonts now
const colors = {
'primary-blue': '#0e2730'
};
module.exports = {
theme: {
container: {
center: true,
padding: '2rem',
},