npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alliage/webserver-sandbox

v0.1.0-beta.2

Published

Webserver sandbox for Alliage

Readme

Alliage Webserver Sandbox

Tool to perform integration tests on Alliage webserver applications.

Description

@alliage/webserver-sandbox extends the @alliage/sandbox package to provide specialized testing capabilities for Alliage webserver applications. It allows you to:

  • Start and stop webserver instances in isolated sandbox environments
  • Make HTTP requests to the server
  • Perform end-to-end integration tests on web applications

Installation

npm install --save-dev @alliage/webserver-sandbox
# or
yarn add -D @alliage/webserver-sandbox

Usage

Basic Example

import { Sandbox } from '@alliage/sandbox';
import { WebserverSandbox } from '@alliage/webserver-sandbox';

async function runWebserverTests() {
  // Create a base sandbox instance
  const sandbox = new Sandbox({
    scenarioPath: './path/to/test/scenario',
  });

  // Create webserver sandbox wrapper
  const webserverSandbox = new WebserverSandbox(sandbox);

  // Initialize the sandbox
  await sandbox.init();

  try {    
    // Start the webserver
    await webserverSandbox.start();

    // Make HTTP requests to test endpoints
    const client = webserverSandbox.getClient();
    const response = await client.get('/api/health');
    
    console.log('Health check:', response.data);
  } finally {
    // Clean up
    await webserverSandbox.stop();
    await sandbox.clear();
  }
}

Using with Vitest/Jest

Here's a comprehensive example using the webserver sandbox with Vitest for integration testing:

import { describe, it, beforeAll, afterAll, expect } from 'vitest';
import { Sandbox } from '@alliage/sandbox';
import { WebserverSandbox } from '@alliage/webserver-sandbox';

describe('Webserver Integration Tests', () => {
  const sandbox = new Sandbox({
    scenarioPath: __dirname,
  });

  const webserverSandbox = new WebserverSandbox(sandbox);

  beforeAll(async () => {
    // Initialize the sandbox environment
    await sandbox.init();
  });

  afterAll(async () => {
    // Clean up webserver and sandbox
    await webserverSandbox.stop();
    await sandbox.clear();
  });

  it('should start a webserver and respond to basic requests', async () => {
    // Start the webserver
    await webserverSandbox.start();

    // Make a GET request to the root endpoint
    const response = await webserverSandbox.getClient().get('/');

    expect(response.status).toBe(200);
    expect(response.data).toEqual({ message: 'Hello world!' });
  });
});

API Reference

Constructor

new WebserverSandbox(sandbox: Sandbox)

| Parameter | Type | Description | |-----------|---------|------------------------------------------------| | sandbox | Sandbox | An initialized Sandbox instance to wrap |

Methods

start(options?: StartOptions): Promise<void>

Starts the webserver in the sandbox environment.

interface StartOptions {
  timeout?: number; // Timeout in milliseconds (default: 30000)
  port?: number;    // Port to start the server on (optional)
  env?: Record<string, string>; // Environment variables
}
stop(): Promise<void>

Stops the running webserver instance.

getClient(): AxiosInstance

Returns an HTTP client (Axios instance) configured to make requests to the running webserver.

// Example usage
const client = webserverSandbox.getClient();

// GET request
const getResponse = await client.get('/api/users');

// POST request with data
const postResponse = await client.post('/api/users', {
  name: 'John Doe',
  email: '[email protected]'
});

// PUT request
const putResponse = await client.put('/api/users/1', {
  name: 'Jane Doe'
});

// DELETE request
const deleteResponse = await client.delete('/api/users/1');
getBaseUrl(): string

Returns the base URL of the running webserver (e.g., http://localhost:3000).

isRunning(): boolean

Returns true if the webserver is currently running, false otherwise.