Sumi
(すみ) is the evolution of the Wiggly framework, maintaining its core strengths as a lightweight framework built on top of Hono while introducing new features. It continues to provide simple server setup with middleware and dynamic routing through a file-based routing system.
- Framework Rename: From Wiggly to Sumi (すみ)
- Simplified Configuration: More intuitive setup with better defaults
- Plugin System: New plugin architecture for extending functionality
- Static File Serving: Beta feature through the Hibana (火花) component
- No Support for Node: With Sumi, you no longer have to worry about a node server sumi supports only bun out of the box
bun install sumi //WIP
import { Sumi } from 'sumi';
const sumi = new Sumi({
port: 3000,
routesDir: './routes',
middlewareDir: './routes/middleware'
});
sumi.burn();
const fetch = sumi.fetch()
export default {
port: /*your port number*/,
fetch
}
The directory structure remains familiar but with some enhancements:
project-root/
├── routes/
│ ├── middleware/
│ │ ├── _index.ts # Global middleware
│ ├── users/
│ │ ├── _middleware.ts # Route-specific middleware
│ │ ├── index.ts # GET /users
│ │ ├── [id].ts # GET /users/:id
│ │ └── [id]/
│ │ └── posts/
│ │ └── index.ts # GET /users/:id/posts
└── static/ # Static files directory (Beta)
└── public/
├── images/
├── css/
└── js/
// routes/users/index.ts
export default {
get: (c) => c.json({ users: [] }),
post: async (c) => {
const body = await c.req.json();
return c.json(body);
}
};
// routes/middleware/_index.ts
export default {
_: async (c, next) => {
c.set('requestTime', Date.now());
await next();
}
};
const sumi = new Sumi({ /*...configs*/ });
// Register a database plugin
sumi.plugin(async (c, next) => {
c.plugin.set('db', database);
await next();
});
// Use in routes
export default {
get: async (c) => {
const db = c.plugin.use('db');
const users = await db.query('SELECT * FROM users');
return c.json(users);
}
};
Sumi introduces Hibana (火花) for static file serving:
import { Sumi, hibana } from 'sumi';
const app = new Sumi({
port: 3000
});
// Beta: Serve static files //WIP
app.use(hibana({
root: './public',
prefix: '/static'
}));
app.burn();
interface SumiOptions {
app?: Hono; // Custom Hono instance
basePath?: string; // Base path for all routes
routesDir?: string; // Routes directory path
middlewareDir?: string; // Middleware directory path
logger?: boolean; // Enable logging
}
# Install dependencies
bun install
# Start development server
bun run dev
# Build for production
bun run build
- Update your imports:
// Old
import Wiggly from 'wiggly';
// New
import { Sumi } from 'sumi';
- Update initialization:
// Old
const app = new Wiggly({
base_path: '/api',
useLogger: true,
port:8080
});
// New
const sumi = new Sumi({
basePath: '/api',
logger: true,
...other configs
});
- Update server start:
// Old
app.serve();
// New
sumi.burn();
const fetch = sumi.fetch()
export default {
port: 5790,
fetch
};
//seems excessive but this is all in favor of bun
MIT