mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5458] feat: add reusable JavaScript functions library for pre-request scripts [Hacktoberfest] #5224
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5224
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5458
Author: @abhishekmaniy
Created: 10/7/2025
Status: 🔄 Open
Base:
main← Head:feat/reusable-functions-library📝 Commits (1)
09adadffeat: add reusable JavaScript functions library for pre-request scripts📊 Changes
13 files changed (+484 additions, -7 deletions)
View changed files
📝
packages/hoppscotch-common/locales/en.json(+15 -0)📝
packages/hoppscotch-common/src/components/http/RequestOptions.vue(+8 -0)➕
packages/hoppscotch-common/src/components/http/ReusableFunctions.vue(+223 -0)📝
packages/hoppscotch-common/src/helpers/RequestRunner.ts(+5 -0)📝
packages/hoppscotch-common/src/helpers/workers/sandbox.worker.ts(+7 -1)➕
packages/hoppscotch-common/src/newstore/reusableFunctions.ts(+141 -0)📝
packages/hoppscotch-data/src/index.ts(+1 -0)➕
packages/hoppscotch-data/src/reusable-functions/index.ts(+39 -0)📝
packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js(+11 -0)📝
packages/hoppscotch-js-sandbox/src/cage-modules/scripting-modules.ts(+9 -1)➕
packages/hoppscotch-js-sandbox/src/cage-modules/utils/reusable-functions.ts(+15 -0)📝
packages/hoppscotch-js-sandbox/src/types/index.ts(+3 -1)📝
packages/hoppscotch-js-sandbox/src/web/pre-request/index.ts(+7 -4)📄 Description
Summary
Implements a reusable JavaScript functions library that allows users to define and store common functions for use across multiple
pre-request scripts. This addresses the need for better script reusability, reduces code duplication, and enhances developer productivity
by providing a centralized function management system.
Key Features
Changes Made
HoppReusableFunctiondata types and validation schemasUsage Example
Create a reusable function:
Use it in any pre-request script:
const timestamp = generateTimestamp();
pw.env.set('currentTimestamp', timestamp);
Technical Implementation
Test Plan
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.