A Node.js/TypeScript client for the Shesha REST API. Provides typed services for authentication and entity querying, with integration tests that can be used as stress/load tests against a Shesha instance.
- Node.js 18+
- npm 9+
npm installAll tests read connection details from tests/config.json. Edit this file to point at your Shesha instance before running any tests.
tests/config.json
{
"baseUrl": "https://your-shesha-instance.example.com",
"username": "admin",
"password": "your-password"
}| Field | Description |
|---|---|
baseUrl |
Root URL of your Shesha API (no trailing slash) |
username |
Username or email address of the account used to authenticate |
password |
Password for the above account |
tests/config.jsonis not committed to source control — keep credentials out of git.
# Run all tests once
npm test
# Run only the entity tests once
npm test -- --testPathPattern=entitiesThe entities test (tests/entities.test.ts) fetches all Shesha.Core.Person records in batches of 50 across 10 concurrent runs. This makes it a useful load/stress test for measuring how a Shesha instance handles sustained parallel API traffic.
- Authenticates once using the credentials in
tests/config.json - Spawns 10 concurrent fetch loops, each paging through every
Personrecord in batches of 50 - Asserts that the total fetched equals the server-reported
totalCounton every run - Logs per-batch and per-run progress to the console
npm run test:entities:loopThis runs the entities test 1 000 times sequentially via scripts/loop-test.js. Each iteration prints a counter (=== Loop N/1000 ===) so you can track progress.
To change the number of iterations, edit scripts/loop-test.js:
const LOOPS = 1000; // change this valueBoth values are constants at the top of tests/entities.test.ts:
const ENTITY_TYPE = 'Shesha.Core.Person'; // entity to query
const BATCH_SIZE = 50; // records per page (maxResultCount)Increase BATCH_SIZE for fewer, larger requests. Decrease it for more, smaller requests. Change ENTITY_TYPE to stress-test a different entity.
The number of concurrent runs per iteration is controlled by the array passed to Promise.all near the bottom of the test:
await Promise.all([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(run => runFetch(run)));Add or remove entries to increase or decrease parallelism.
src/
auth/ AuthService — login and token management
entities/ EntityService — getAll with pagination
types/ Shared TypeScript interfaces
tests/
config.json Instance connection details (edit before running)
entities.test.ts Entity pagination + stress test
scripts/
loop-test.js Runs the entities test N times sequentially
npm run buildOutput is written to dist/.