CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-confusing-browser-globals

A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit window qualifier

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-10/

SPA Router Fallback Server

Build a development server that handles client-side routing for Single Page Applications (SPAs). The server should serve static files normally, but fall back to serving index.html for any route that doesn't match a static file.

Requirements

Your development server should:

  1. Serve static files (HTML, JS, CSS) from a public directory
  2. Fall back to serving index.html for non-file routes (like /about, /users/123)
  3. Start a server on a configurable port

Test Cases

Static File Serving

  • Requesting / returns the index.html file content with status 200 @test
  • Requesting /app.js when app.js exists returns the JavaScript file with status 200 @test

SPA Route Fallback

  • Requesting /about (which doesn't exist as a file) returns index.html content with status 200 @test
  • Requesting /users/123 (nested route) returns index.html content with status 200 @test

Implementation

@generates

API

/**
 * Creates and starts a development server with SPA fallback support
 * @param {Object} options - Server configuration options
 * @param {number} options.port - Port number to listen on (default: 3000)
 * @param {string} options.publicDir - Directory to serve static files from (default: './public')
 * @returns {Object} Server instance with a close() method
 */
function createServer(options);

Dependencies { .dependencies }

connect { .dependency }

Provides HTTP server middleware functionality for handling requests and serving static files.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-confusing-browser-globals

tile.json