0.1.6 • Published 2 years ago

@examind/ltijs-firestore-scheduler v0.1.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

LTIJS Cloud Function script to be used with LTIJS Firestore to purge stale documents.

Introduction

This package purges stale documents created by @examind/ltijs-firestore by deploying a Firebase Function that runs periodically.

Installation

Install Firebase CLI:

npm install -g firebase-tools@10.0.1

Create a new empty folder and inside of it, initialize a Firebase project:

firebase init functions

Select the following options:

  • Are you ready to proceed (Y/n): y
  • Choose your account
  • Choose your project
  • What language would you like to use to write Cloud Functions? TypeScript
  • Do you want to use ESLint to catch probable bugs and enforce style? (Y/n): n
  • Do you want to install dependencies with npm now? (Y/n): y

Upgrade firebase-admin package inside the functions folder:

cd functions
npm install firebase-admin@latest

Install @examind/ltijs-firestore-scheduler inside the functions folder:

cd functions
npm install @examind/ltijs-firestore-scheduler

Replace contents of functions/index.ts with:

export { purgeStaleDocuments } from '@examind/ltijs-firestore-scheduler';

Optional: set environment variables to change deployment options:

process.env.CLOUD_FUNCTION_REGION = 'northamerica-northeast1';
process.env.CLOUD_FUNCTION_TIMEOUT_SECONDS = '300';
process.env.CLOUD_FUNCTION_MEMORY = '1GB';
process.env.CLOUD_FUNCTION_SCHEDULE = 'every 5 minutes';

export { purgeStaleDocuments } from '@examind/ltijs-firestore-scheduler';

Available deployment options:

Environment VariableDescriptionDefault
CLOUD_FUNCTION_REGIONRegionus-central1
CLOUD_FUNCTION_TIMEOUT_SECONDSTimeout120
CLOUD_FUNCTION_MEMORYMemory256MB
CLOUD_FUNCTION_SCHEDULEScheduleevery 15 minutes
firebase deploy --only functions

Contribution

If you find a bug or think that something is hard to understand, please open an issue. Pull requests are also welcome 🙂

Publish

  • Bump version in package.json
  • npm install
  • Commit with message: Release {version, e.g. 0.1.6}
0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago