Home

Getting Started

Get up and running with Kempo Server in just a few steps.

Installation

1. Install the npm package.

npm install kempo-server

2. Add it to your package.json scripts, use the --root flag to tell it where the root of your site is.

{
...
"scripts": {
"start": "kempo-server --root public"
}
...
}

3. Run it in your terminal.

npm run start

Basic Project Structure

Once installed, create a basic project structure:

my-project/
├─ public/ # Your web root
│ ├─ index.html # Homepage
│ ├─ styles.css # CSS files
│ ├─ api/ # API routes
│ │ ├─ hello/
│ │ │ ├─ GET.js # GET /api/hello/
│ │ ├─ users/
│ │ │ ├─ GET.js # GET /api/users/
│ │ │ ├─ POST.js # POST /api/users/
├─ package.json
├─ .config.json # Optional configuration

Your First Route

Create a simple API endpoint:

1. Create the directory structure

mkdir -p public/api/hello

2. Create your first route file

Create public/api/hello/GET.js:

// public/api/hello/GET.js
export default async function(request, response) {
const { name } = request.query;
const message = name ? `Hello ${name}!` : 'Hello World!';

response.json({ message, timestamp: new Date().toISOString() });
}

3. Test your route

Start your server and visit:

Command Line Options

Kempo Server supports several command line options:

Basic example:

kempo-server --root public --port 8080 --host 0.0.0.0 --verbose

Configuration File Examples

You can specify different configuration files for different environments:

# Development
kempo-server --root public --config dev.config.json

# Staging
kempo-server --root public --config staging.config.json

# Production with absolute path
kempo-server --root public --config /etc/kempo/production.config.json

# Mix with other options
kempo-server --root dist --port 8080 --config production.config.json

What's Next?

Now that you have Kempo Server running, explore these topics: