Registry / web-framework / server

server

JSON →
library0.0.0jsnpmunverified

server.js is a Node.js framework designed for building web applications and APIs with a focus on simplicity and ease of use. It provides a comprehensive set of features out-of-the-box, including body and file parsers, cookies, sessions, WebSockets (via Socket.io), Redis integration, gzip compression, favicon handling, CSRF protection, and SSL support. This approach aims to minimize configuration and allow developers to concentrate on business logic. The package is currently stable at version 1.0.42, with frequent minor updates addressing bug fixes and introducing small enhancements, as seen in its recent release history. It differentiates itself by bundling many common utilities that often require separate middleware in other frameworks, while still offering compatibility with the Express middleware ecosystem for extended functionality. It explicitly recommends Node.js 8.x.y LTS or newer (minimum 7.6.0), indicating a CommonJS-first approach in its current major version.

npm install server
INSTALL
IMPORT
SIG · SERVER
S
server
web-frameworkjavascriptv0.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

server
const server = require('server');
The primary export is a function to start the server. This package is primarily CommonJS-based.
get, post
const { get, post } = require('server').router;
import { get, post } from 'server/router';
Router methods like `get`, `post`, `put`, `del`, `socket` are available via `server.router` or direct import from `server/router`. ESM imports are not officially supported in the 1.x series.
render, redirect
const { render, redirect } = require('server').reply;
import { render, redirect } from 'server/reply';
Reply helper functions for rendering templates or redirecting are found on `server.reply`. ESM imports are not officially supported in the 1.x series.

This quickstart code initializes a server listening on port 8080 with a GET route responding 'Hello world' and a POST route logging request data.

const server = require('server'); const { get, post } = server.router; // Launch server with options and a couple of routes server({ port: 8080 }, [ get('/', ctx => 'Hello world'), post('/', ctx => { console.log(ctx.data); return 'ok'; }) ]);
Debug
Known issues
gotchaThe package officially supports Node.js versions >=7.6.0 and recommends 8.x.y LTS. While it might run on newer Node.js versions, compatibility beyond Node 8.x LTS is not explicitly guaranteed in the documentation, which could lead to unexpected behavior.
fix
Ensure your Node.js environment is within the recommended range or thoroughly test on newer versions for full compatibility.
affects: <=1.0.42
breakingAs of version 1.0.12, sending only a status code no longer automatically sets a default body (which was previously handled by Express). To send an empty body with a status, you must explicitly call `.send()` after `.status(NUMBER)`.
fix
Update your response handling from `ctx.status(200)` to `ctx.status(200).send()` when no body is intended.
affects: >=1.0.12
gotchaThe package primarily uses CommonJS `require()` syntax in all documentation and examples. While Node.js supports ESM, `server` does not explicitly document or guarantee full ESM compatibility. Attempting to use `import` statements might lead to module resolution errors or unexpected behavior.
fix
Adhere to CommonJS `require()` syntax for importing modules and functions from `server`.
affects: <=1.0.42
gotchaPrior to version 1.0.7, there were inconsistent path resolution issues when using Yarn (compared to npm) with wildcard routes, specifically affecting `path-to-regexp-wrap` behavior.
fix
Upgrade to `server` version 1.0.7 or newer to resolve `path-to-regexp-wrap` inconsistencies with Yarn.
affects: <1.0.7
Errors
Common errors & fixes
TypeError: ctx.status(...).send is not a function
Attempting to send an empty body by just setting the status code, which was a behavior change in version 1.0.12.
fix
Explicitly call `.send()` after `.status(NUMBER)`, e.g., `ctx.status(200).send()`.
Error: No response from the server
This error or similar warnings (like 'No response was sent from the server') can occur if a route handler does not explicitly return a value or call a response method (e.g., `ctx.send()`, `ctx.render()`, `ctx.redirect()`). Improved error handling for this was added in 1.0.9 and 1.0.13.
fix
Ensure all route handlers either return a value (which `server` then sends as the response) or explicitly call a response method on the `ctx` object.
Inconsistent routing with '*' wildcard using Yarn
Prior to version 1.0.7, there were known issues where wildcard routes (e.g., `get('*', ...)`) behaved differently when `server` was installed via Yarn compared to npm due to `path-to-regexp-wrap` resolution.
fix
Upgrade `server` to version 1.0.7 or higher. If upgrading is not an option, consider using npm instead of Yarn, or avoid wildcard routes in affected versions.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
server — npm install server · libregistry