Skip to content

Instantly share code, notes, and snippets.

View beardsleym's full-sized avatar
👻

Matthew Beardsley beardsleym

👻
View GitHub Profile
@JamieCurnow
JamieCurnow / useFirebase.ts
Created April 7, 2022 10:33
Using firebase in a back-end node service
// Get the imports
import { credential } from 'firebase-admin'
import { initializeApp } from 'firebase-admin/app'
import { getFirestore, CollectionReference, DocumentData } from 'firebase-admin/firestore'
// get the service account - IT SHOULD BE GIT IGNORED!
// Make one and download it here:
// https://console.firebase.google.com/u/0/project/your-project-name/settings/serviceaccounts/adminsdk
const serviceAccount = require('../../firebase-admin-service-account.json')
@JamieCurnow
JamieCurnow / firestore.ts
Last active June 28, 2023 23:27
Using Firestore with Typescript - including update helper
/**
* This Gist is part of a medium article - read here:
* https://jamiecurnow.medium.com/using-firestore-with-more-typescript-8058b6a88674
*/
// import firstore (obviously)
import { firestore } from "firebase-admin"
// Here's the helper type for paths:
type PathImpl<T, K extends keyof T> =
@IsaiahByDayah
IsaiahByDayah / resize.ts
Last active March 1, 2024 07:56
Example express endpoint that resizes an image from B2 Cloud Storage
import * as admin from "firebase-admin"
import express from "express"
import sharp, { ResizeOptions, OutputOptions } from "sharp"
import fetch from "cross-fetch"
import FileType from "file-type"
import { parseQueryNumber, parseQueryString } from "../some/extra/util/functions"
import { Photo } from "../some/custom/types"
const router = express.Router()