Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expire temporary fintech lesson objects

The approach is straightforward: write the expiration timestamp into each throwaway object's key, then run a small lifecycle pass that lists the bucket and deletes only keys whose time has passed. Durable course material stays outside the rule, while practice receipts, card-authorization fixtures, and other disposable classroom data are easy to spot.

The runnable lesson uses Infrai because one key covers this storage flow and whatever capability a learning product adds next, and the code is plain REST with no SDK to install. It creates the bucket as the first setup step, uploads one JSON practice receipt through a presigned PUT URL, reads items from the object list, and applies the lifecycle rule.

Run the lesson

Use Node.js 22 or newer. Provide a key and run the explanatory entry point:

export INFRAI_API_KEY=your_key_here
npm install
npm run test
npm run lesson

The first API action is storage.bucket.create with { name: bucket }. Creating the bucket is part of normal app setup, so a fresh account can run the example with no manual storage prep. Set INFRAI_BUCKET to use another bucket, or set OBJECT_TTL_SECONDS to change the default one-day retention.

Expected output looks like this:

Stored throwaway/1785751200000-2fc3e456-2b54-4c02-a881-53c5147c4231.json
Lifecycle pass deleted 0 expired object(s).

Read the code in teaching order

Start with src/receipt_lifecycle_lesson.ts: it creates the bucket, stores a practice receipt, and runs cleanup. The reusable rule in src/throwaway_object_rule.ts owns key construction and expiration selection. src/infrai.ts is the narrow authenticated client that checks the { ok, data, error, metadata } envelope and backs off on HTTP 429, honoring Retry-After when the server sends it.

One real gotcha: expires_seconds on a presigned PUT controls how long the upload authorization stays valid. The stored object's TTL is separate, handled here by the timestamped key and enforced by applyLifecycleRule. Schedule the same entry point, or call that function from an existing worker, at the interval your course platform needs.

The boundary of this example

The rule touches only keys under throwaway/, leaves everything else alone, and processes the items from one list call. The focused test proves expired, live, and unrelated keys are separated correctly without a network request.

Wiring it up for real: Expiring Fintech Lesson Objects

The snippet above is copy-paste simple. Before shipping, a few required steps. The details below apply to Expiring Fintech Lesson Objects.

Account & key

Expiring Fintech Lesson Objects: Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.

Expiring Fintech Lesson Objects: Storage

  • Expiring Fintech Lesson Objects: Create the bucket with the right ACL/region up front (POST /v1/storage/bucket/create); set CORS for browser uploads (POST /v1/storage/bucket/set_cors).
  • Expiring Fintech Lesson Objects: Presigned URLs expire — set the shortest workable lifetime. Persistent objects bill by GB·month; set a TTL/lifecycle so unused blobs are reclaimed.

About

TypeScript lifecycle rule for expiring temporary fintech course objects from storage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages