Illust
MarketplaceGlobal Art MapBlogTwitter
  • Illust.space
  • .github
    • pull_request_template
  • docs
    • Illust Dev Docs
    • Packages
    • process
    • dev-workflow
      • Deployment
      • Development process
      • Visual Studio Code
    • libraries
      • Storybook
      • Act
      • Aframe
      • Chakra UI
      • Cypress
      • Hosting
      • React Three Fiber
        • Shadows
      • Firebase
        • Firestore
      • zustand
      • Firebase Url Shotener
    • Flows
      • User Sign In
      • Aframe AR Map
  • packages
    • Illust API
    • Illust Marketplace
    • Migrate DB
    • scraper
    • Illust Shared
    • Illust WebAR Discovery App
  • Illust Code Style Guide
    • JavaScript/TypeScript
    • Code Orgainzation
    • React
    • Testing
  • Knowledge Base
    • React
      • Hooks
Powered by GitBook
On this page
  • Testing
  • Valid user accounts
  • Configuration
  • Setting Up An endpoint and collection

Was this helpful?

  1. packages

Illust API

PreviouspackagesNextIllust Marketplace

Last updated 3 years ago

Was this helpful?

The Firebase Cloud Functions for the Illust marketplace and WebAR sites.

This uses Express/Typescript to set up the cloud functions.

Testing

To run spin up the Firebase emulator, and run all tests:

yarn test

However, it can be faster to run the emulator in a separate terminal, so it doesn't have to spin up every time. To do that, run the following commands in separate terminals:

yarn test:emulator
yarn test:run

This also lets you more easily specify a path to test, like:

yarn test:run src/routes/users.test.ts

Valid user accounts

There is one valid user account set up for testing. Here are the credentials:

Auth Token: good-token User UID: alice

See for more details.

Configuration

yarn firebase use staging # or prod
yarn firebase functions:config:get # Get the current config
yarn firebase functions:config:set marketplace.varname=Value # Set a new value

Setting Up An endpoint and collection

  1. Update firebase.json rewrites with source and function name. Wild cards are supported ex:

    { "source": "/pop", "function": "pop" },
    { "source": "/pop/**", "function": "pop" }
  2. import { popApp } from "./routes/pop";
    export const pop = functions.https.onRequest(popApp);
  3. If adding a new collection add it to the shared package and export the interface. ex

    export interface Pop {
      id: string;
      claimer: string;
      tokenId: string;
    }
  4. // collections.ts
    pops = this.getCollection<Pop>("pops");
    // In API code
    import { fb } from "~/lib/fb";
    
    await fb.db.pops.get();
  5. Verify your route has appropriate CORS settings

    popApp.use(cors(), json());

Instead of env vars, firebase cloud functions have their own configuration system. For local development, add values to . For prod and staging, use:

Default values are stored in

Add a route in . Add a function export in this file. ex:

If adding a new collection add it to the file's Firestore class

setupTests.ts
./.runtimeconfig.json
src/defaultConfig.ts
index.ts
collections.ts