Potato Framework
raw JSON → 1.2.0 verified Sat May 09 auth: no javascript
A simple HTTP framework for Node.js (version 1.2.0). Provides a minimal API for building web servers with routing, request handling, and middleware support. Designed for quick prototyping and small applications. Differentiates by focusing on simplicity and a single main export called Sweet Potato. Active development, but limited documentation and community adoption compared to Express.js. TypeScript types included.
Common errors
error TypeError: Cannot read properties of undefined (reading 'path') ↓
cause SweetPotato handle is called without proper binding; 'this' is undefined.
fix
Bind the handle method:
const server = createServer(app.handle.bind(app)); error SyntaxError: Unexpected token 'export' ↓
cause Using CommonJS require() instead of ESM import.
fix
Use
import statements and ensure "type": "module" in package.json error ERR_UNSUPPORTED_ESM_URL_SCHEME ↓
cause Node.js version below 18.12.0 cannot resolve ESM imports.
fix
Upgrade Node.js to v18.12.0 or later.
Warnings
gotcha SweetPotato's handle method must be passed directly, not wrapped in a function, to preserve `this` context. ↓
fix Use `app.handle.bind(app)` or wrap in arrow function: `(req, res) => app.handle(req, res)`
deprecated The old `createServer` import path has been removed. ↓
fix Remove any import from 'potato-framework/createServer'
breaking Node.js version 18.12.0 or higher required due to ESM support. ↓
fix Upgrade Node.js to v18.12.0+ or use a transpiler like Babel.
gotcha Route parameter extraction is case-sensitive and does not URL-decode automatically. ↓
fix Manually decode params with `decodeURIComponent()` if needed.
Install
npm install potato-framework yarn add potato-framework pnpm add potato-framework Imports
- SweetPotato wrong
const SweetPotato = require('potato-framework')correctimport { SweetPotato } from 'potato-framework' - default wrong
import { default } from 'potato-framework'correctimport Potato from 'potato-framework' - Request wrong
const { Request } = require('potato-framework')correctimport { Request } from 'potato-framework' - Response wrong
import { res } from 'potato-framework'correctimport { Response } from 'potato-framework'
Quickstart
import { SweetPotato } from 'potato-framework';
import { createServer } from 'http';
const app = new SweetPotato();
app.get('/', (req, res) => {
res.statusCode = 200;
res.end('Hello Potato!');
});
const server = createServer(app.handle);
server.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});