Skip to content

Installation

Shokupan requires Bun to be installed on your system.

If you don’t have Bun installed yet:

Terminal window
# macOS, Linux, and WSL
curl -fsSL https://bun.sh/install | bash
# Windows (PowerShell)
powershell -c "irm bun.sh/install.ps1|iex"

Verify the installation:

Terminal window
bun --version

Install Shokupan in your project:

Terminal window
bun add shokupan
Terminal window
mkdir my-shokupan-app
cd my-shokupan-app
bun init -y
Terminal window
bun add shokupan

Create a file named index.ts:

import { Shokupan } from 'shokupan';
const app = new Shokupan({
port: 3000,
development: true
});
app.get('/', (ctx) => {
return { message: 'Hello, Shokupan!' };
});
app.get('/users/:id', (ctx) => {
return {
id: ctx.params.id,
name: 'Alice',
email: 'alice@example.com'
};
});
app.post('/users', async (ctx) => {
const body = await ctx.body();
return {
message: 'User created',
data: body
};
});
console.log('🍞 Server running at http://localhost:3000');
app.listen();
Terminal window
bun run index.ts

Your server is now running! Open http://localhost:3000 in your browser.

For automatic reloading during development, use the --watch flag:

Terminal window
bun --watch index.ts

Now your server will automatically restart when you make changes to your code.

A typical Shokupan project structure might look like:

my-shokupan-app/
├── src/
│ ├── controllers/
│ │ ├── user.controller.ts
│ │ └── post.controller.ts
│ ├── middleware/
│ │ ├── auth.ts
│ │ └── logger.ts
│ ├── services/
│ │ └── user.service.ts
│ └── main.ts
├── package.json
└── tsconfig.json

For the best experience, configure your tsconfig.json:

{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ESNext"],
"types": ["bun-types"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true,
"esModuleInterop": true
}
}

The important settings for Shokupan are:

  • experimentalDecorators: true - Required for controller decorators
  • emitDecoratorMetadata: true - Enables metadata for dependency injection

Now that you have Shokupan installed, learn about: