CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

pubnub/pubnub-functions

Develop serverless edge functions with PubNub Functions 2.0

Agent Success

Agent success rate when using this tile

93%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.79x

Baseline

Agent success rate without this tile

52%

Overview
Eval results
Skill reviews
Files

task.mdevals/scenario-3/

API Request Throttle Function

Context

You are building a PubNub Before Publish function that acts as a throttle for an API channel. Users on a "free" tier are allowed 100 requests per hour and "pro" tier users get 1000 per hour. The function should check the user's request count within the current time window and either allow or block the message. The function also needs to look up the user's tier from storage and attach remaining quota information to the message.

Be mindful that PubNub Functions have strict limits on the number of external operations that can be performed in a single execution.

Task

Write a PubNub Before Publish function (throttle.js) that:

  1. Determines the user's tier and enforces the corresponding request limit per time window
  2. Blocks messages that exceed the limit
  3. Attaches remaining quota information to allowed messages
  4. Handles unexpected errors in a way that keeps the system available
  5. Operates efficiently within the platform's execution constraints

Expected Outputs

  • A throttle.js file containing a complete PubNub Function implementing the request throttle.
tessl i pubnub/pubnub-functions@0.1.4

evals

SKILL.md

tile.json