{"_id":"@alliage/webserver-sandbox","_rev":"4-db4bd528337f77ac21d6c22545a62746","name":"@alliage/webserver-sandbox","dist-tags":{"latest":"0.1.0-beta.2"},"versions":{"0.1.0-beta.0":{"name":"@alliage/webserver-sandbox","version":"0.1.0-beta.0","author":{"name":"bo.lebon@gmail.com"},"license":"ISC","_id":"@alliage/webserver-sandbox@0.1.0-beta.0","maintainers":[{"name":"borislebon","email":"bo.lebon@gmail.com"},{"name":"thehumblejester","email":"the.humble.jester@gmail.com"}],"homepage":"https://github.com/alliage-framework/web#readme","bugs":{"url":"https://github.com/alliage-framework/web/issues"},"dist":{"shasum":"baf092749a599d09f28385310b3e11b245852edb","tarball":"https://registry.npmjs.org/@alliage/webserver-sandbox/-/webserver-sandbox-0.1.0-beta.0.tgz","fileCount":6,"integrity":"sha512-fblcyn4r2XXcCtmEnuuRqHS97JkNdrJJgWa0kJCMpnc7VrqeUrOQ0YZr9OhWNN1HuP0ad3JzSikCg7q8Ajjmbw==","signatures":[{"sig":"MEYCIQDjqu4RrsI6z7DYwcZ4FPp0M6TpJLSxM2on5F5iwGg3cAIhAP+Xleq6mbPcPORvHutsuafMbQQxBT6QVv3it6czVMwx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17960},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"b31bc17873915029257fb5629eea2472120c6f91","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"borislebon","email":"bo.lebon@gmail.com"},"repository":{"url":"git+https://github.com/alliage-framework/web.git","type":"git"},"_npmVersion":"lerna/6.6.2/node@v18.16.0+x64 (linux)","description":"Webserver sandbox for Alliage","directories":{},"_nodeVersion":"18.16.0","dependencies":{"axios":"^0.21.0","get-port":"^5.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"@alliage/sandbox":"^1.0.0-beta.1","@alliage/framework":"^1.0.0-beta.2","@alliage/webserver":"^0.1.0-beta.0"},"_npmOperationalInternal":{"tmp":"tmp/webserver-sandbox_0.1.0-beta.0_1683908387601_0.2120620584119426","host":"s3://npm-registry-packages"}},"0.1.0-beta.1":{"name":"@alliage/webserver-sandbox","version":"0.1.0-beta.1","author":{"name":"bo.lebon@gmail.com"},"license":"ISC","_id":"@alliage/webserver-sandbox@0.1.0-beta.1","maintainers":[{"name":"borislebon","email":"bo.lebon@gmail.com"}],"homepage":"https://github.com/alliage-framework/web#readme","bugs":{"url":"https://github.com/alliage-framework/web/issues"},"dist":{"shasum":"fcfe1211f6a0fabbf4792a053a145e7bea653152","tarball":"https://registry.npmjs.org/@alliage/webserver-sandbox/-/webserver-sandbox-0.1.0-beta.1.tgz","fileCount":5,"integrity":"sha512-0Wg9+wd9M1ORtn13+7FmrkC/VBTaDptHAv/xto4cRb2Qg6QoJ1+oM+c0HW09qmJXdtjSS+0afcAcWikib8srFQ==","signatures":[{"sig":"MEYCIQC3UcowyljqavA9G381a2mbCjeywDBHLHjKD/uH24C3xwIhANfuJZaM4A24CvCLWOVURmKIgDYZhvIs3V2WJwu4jdBS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10296},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"fa2b5c23766c2d6ed8bc7f628f26691407e43075","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"borislebon","email":"bo.lebon@gmail.com"},"repository":{"url":"git+https://github.com/alliage-framework/web.git","type":"git"},"_npmVersion":"10.8.2","description":"Webserver sandbox for Alliage","directories":{},"_nodeVersion":"20.19.2","dependencies":{"axios":"^1.9.0","get-port":"^7.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"@alliage/sandbox":"^1.0.0-beta.4","@alliage/framework":"^1.0.0-beta.3","@alliage/webserver":"0.1.0-beta.1"},"_npmOperationalInternal":{"tmp":"tmp/webserver-sandbox_0.1.0-beta.1_1748632346221_0.3194283434257943","host":"s3://npm-registry-packages-npm-production"}},"0.1.0-beta.2":{"name":"@alliage/webserver-sandbox","version":"0.1.0-beta.2","description":"Webserver sandbox for Alliage","type":"module","publishConfig":{"access":"public"},"main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/alliage-framework/web.git"},"author":{"name":"bo.lebon@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/alliage-framework/web/issues"},"homepage":"https://github.com/alliage-framework/web#readme","peerDependencies":{"@alliage/framework":"^1.0.0-beta.3","@alliage/sandbox":"^1.0.0-beta.4","@alliage/webserver":"0.1.0-beta.2"},"dependencies":{"axios":"^1.9.0","get-port":"^7.1.0"},"_id":"@alliage/webserver-sandbox@0.1.0-beta.2","gitHead":"4696313051fed9f147bb2db23b19f720264cbe12","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-uZgnGeyPF5rtWbgcPLe2jh/9JXr5P+n55AOmVixdphcSKMpXuVC2mE3CqEvyryqLvtTNneM3cRNT9Y8cXdEtGA==","shasum":"4bf03239fca74cba6a47d6598a29f0c378431889","tarball":"https://registry.npmjs.org/@alliage/webserver-sandbox/-/webserver-sandbox-0.1.0-beta.2.tgz","fileCount":5,"unpackedSize":10296,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCGfejkzOB74wVhyc/oUiOVQ1PEC6qweH1mB3Y6nGNrSQIgWMHZm02kKP7Xlr3xX8b8BSlHEEz+VF80aNCuybNJfrI="}]},"_npmUser":{"name":"borislebon","email":"bo.lebon@gmail.com"},"directories":{},"maintainers":[{"name":"borislebon","email":"bo.lebon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/webserver-sandbox_0.1.0-beta.2_1758477481004_0.3280968565557798"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-12T16:19:47.541Z","modified":"2025-09-21T17:58:01.441Z","0.1.0-beta.0":"2023-05-12T16:19:47.763Z","0.1.0-beta.1":"2025-05-30T19:12:26.387Z","0.1.0-beta.2":"2025-09-21T17:58:01.208Z"},"bugs":{"url":"https://github.com/alliage-framework/web/issues"},"author":{"name":"bo.lebon@gmail.com"},"license":"ISC","homepage":"https://github.com/alliage-framework/web#readme","repository":{"type":"git","url":"git+https://github.com/alliage-framework/web.git"},"description":"Webserver sandbox for Alliage","maintainers":[{"name":"borislebon","email":"bo.lebon@gmail.com"}],"readme":"# Alliage Webserver Sandbox\n\nTool to perform integration tests on Alliage webserver applications.\n\n## Description\n\n`@alliage/webserver-sandbox` extends the [`@alliage/sandbox`](https://github.com/alliage-framework/sandbox) package to provide specialized testing capabilities for Alliage webserver applications. It allows you to:\n\n- Start and stop webserver instances in isolated sandbox environments\n- Make HTTP requests to the server\n- Perform end-to-end integration tests on web applications\n\n## Installation\n\n```bash\nnpm install --save-dev @alliage/webserver-sandbox\n# or\nyarn add -D @alliage/webserver-sandbox\n```\n\n## Usage\n\n### Basic Example\n\n```typescript\nimport { Sandbox } from '@alliage/sandbox';\nimport { WebserverSandbox } from '@alliage/webserver-sandbox';\n\nasync function runWebserverTests() {\n  // Create a base sandbox instance\n  const sandbox = new Sandbox({\n    scenarioPath: './path/to/test/scenario',\n  });\n\n  // Create webserver sandbox wrapper\n  const webserverSandbox = new WebserverSandbox(sandbox);\n\n  // Initialize the sandbox\n  await sandbox.init();\n\n  try {    \n    // Start the webserver\n    await webserverSandbox.start();\n\n    // Make HTTP requests to test endpoints\n    const client = webserverSandbox.getClient();\n    const response = await client.get('/api/health');\n    \n    console.log('Health check:', response.data);\n  } finally {\n    // Clean up\n    await webserverSandbox.stop();\n    await sandbox.clear();\n  }\n}\n```\n\n### Using with Vitest/Jest\n\nHere's a comprehensive example using the webserver sandbox with Vitest for integration testing:\n\n```typescript\nimport { describe, it, beforeAll, afterAll, expect } from 'vitest';\nimport { Sandbox } from '@alliage/sandbox';\nimport { WebserverSandbox } from '@alliage/webserver-sandbox';\n\ndescribe('Webserver Integration Tests', () => {\n  const sandbox = new Sandbox({\n    scenarioPath: __dirname,\n  });\n\n  const webserverSandbox = new WebserverSandbox(sandbox);\n\n  beforeAll(async () => {\n    // Initialize the sandbox environment\n    await sandbox.init();\n  });\n\n  afterAll(async () => {\n    // Clean up webserver and sandbox\n    await webserverSandbox.stop();\n    await sandbox.clear();\n  });\n\n  it('should start a webserver and respond to basic requests', async () => {\n    // Start the webserver\n    await webserverSandbox.start();\n\n    // Make a GET request to the root endpoint\n    const response = await webserverSandbox.getClient().get('/');\n\n    expect(response.status).toBe(200);\n    expect(response.data).toEqual({ message: 'Hello world!' });\n  });\n});\n```\n\n### API Reference\n\n#### Constructor\n\n```typescript\nnew WebserverSandbox(sandbox: Sandbox)\n```\n\n| Parameter | Type    | Description                                    |\n|-----------|---------|------------------------------------------------|\n| sandbox   | Sandbox | An initialized [Sandbox](https://github.com/alliage-framework/sandbox) instance to wrap       |\n\n#### Methods\n\n##### `start(options?: StartOptions): Promise<void>`\n\nStarts the webserver in the sandbox environment.\n\n```typescript\ninterface StartOptions {\n  timeout?: number; // Timeout in milliseconds (default: 30000)\n  port?: number;    // Port to start the server on (optional)\n  env?: Record<string, string>; // Environment variables\n}\n```\n\n##### `stop(): Promise<void>`\n\nStops the running webserver instance.\n\n##### `getClient(): AxiosInstance`\n\nReturns an HTTP client (Axios instance) configured to make requests to the running webserver.\n\n```typescript\n// Example usage\nconst client = webserverSandbox.getClient();\n\n// GET request\nconst getResponse = await client.get('/api/users');\n\n// POST request with data\nconst postResponse = await client.post('/api/users', {\n  name: 'John Doe',\n  email: 'john@example.com'\n});\n\n// PUT request\nconst putResponse = await client.put('/api/users/1', {\n  name: 'Jane Doe'\n});\n\n// DELETE request\nconst deleteResponse = await client.delete('/api/users/1');\n```\n\n##### `getBaseUrl(): string`\n\nReturns the base URL of the running webserver (e.g., `http://localhost:3000`).\n\n##### `isRunning(): boolean`\n\nReturns `true` if the webserver is currently running, `false` otherwise.\n","readmeFilename":"README.md"}