This file contains hidden or 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
import { timestamp, build, files } from '$service-worker'; | |
const name = `cache-${timestamp}`; | |
self.addEventListener('install', (event) => { | |
event.waitUntil(caches.open(name).then((cache) => cache.addAll(['/', ...build, ...files]))); | |
}); | |
self.addEventListener('activate', (event) => { | |
event.waitUntil( |
This file contains hidden or 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
const personModel = [ | |
{ label: "First", value: "first" }, | |
{ label: "Last", value: "last" }, | |
{ label: "Address1", value: "address1" }, | |
{ label: "Address2", value: "address2" }, | |
{ label: "City", value: "city" }, | |
{ label: "State", value: "state" }, | |
{ label: "Zip", value: "zip" }, | |
{ label: "Zip4", value: "zip4" }, |
This file contains hidden or 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
<script async | |
src="https://maps.googleapis.com/maps/api/js?key=***YOURAPIKEY***&libraries=places&callback=initMap"> | |
</script> | |
<script> | |
window.initMap= function(){ | |
const input = document.querySelector('input[name="address"]'); | |
const options = { | |
componentRestrictions: { country: "us" }, | |
fields: ["address_components", "geometry", "icon", "name"], | |
types: ["establishment"], |
This file contains hidden or 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
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | |
// https://scotthelme.co.uk/content-security-policy-an-introduction/ | |
// scanner: https://securityheaders.com/ | |
const rootDomain = `your-domain.com`; // or your server IP for dev | |
const directives = { | |
'img-src': [ | |
"*", | |
"'self'", |
This file contains hidden or 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
<-- place this in the Custom Code section, or in a clode block below the form --> | |
<script> | |
var form= document.querySelector('form'); | |
var submitBtn= document.getElementById('submit'); | |
var textareaWrap= document.createElement('div'); | |
textareaWrap.className= 'relative db cf'; | |
var textareaLabel= document.createElement('label'); | |
textareaLabel.innerHTML= 'Textarea Label Here'; | |
textareaWrap.appendChild(textareaLabel); | |
var textarea= document.createElement('textarea'); |
This file contains hidden or 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
import pkg from 'pdf-lib/cjs/index.js'; | |
const { PDFDocument } = pkg; | |
export const get = async (req, context) => { | |
const pdfDoc = await PDFDocument.create(); | |
const page = pdfDoc.addPage(); | |
page.drawText('You can create PDFs!'); | |
const pdfBytes = await pdfDoc.save(); | |
return { | |
body: Buffer.from(pdfBytes, 'binary'), |
This file contains hidden or 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
import { firebase } from "$services/firebaseAdmin"; | |
export const get = async (req, context) => { | |
const globalRef = firebase.firestore().collection('global'); | |
let data = { | |
now: Date.now() | |
}; | |
const snapshot = await globalRef.get(); | |
snapshot.forEach(doc => { |
This file contains hidden or 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
import admin from "firebase-admin"; | |
if (!admin.apps.length) { | |
admin.initializeApp({ | |
credential: admin.credential.applicationDefault(), | |
databaseURL: 'your-url' // ... | |
}); | |
}; | |
const firebase = admin; |
This file contains hidden or 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
import { initializeApp } from 'firebase/app'; | |
import { getAuth, onAuthStateChanged } from "firebase/auth"; | |
import { getFirestore } from 'firebase/firestore'; | |
import { getStorage } from "firebase/storage"; | |
let ssrAuthed = window.ssrUser; | |
const firebaseConfig = { | |
// ... | |
}; |
This file contains hidden or 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
<script> | |
import "./styles.css"; | |
import { session } from "$app/stores"; | |
import { onMount, setContext } from "svelte"; | |
import { writable } from "svelte/store"; | |
let store = writable({}); | |
setContext("store", store); | |
$: user = $session.user || null; | |
onMount(async () => { |