PlaycademyPlaycademy

Development

Run your backend locally with hot reload

Overview

The playcademy dev command starts a local backend development server that serves your API routes.

It includes routes for integrations — like Timeback — out of the box.

Using Vite?

The @playcademy/vite-plugin package automatically starts playcademy dev for you when you run bun dev.

It is highly recommended to use the Vite Plugin instead of the CLI dev server.

Starting the Dev Server

Command
$ playcademy dev
Output
✔ Project API started: http://localhost:8788/api/health GET/api/hello GET, POST✦ Press ctrl+c to stop

Local Development

When you run playcademy dev, you get a couple of built-in utility routes:

EndpointPurpose
http://localhost:8788/apiAPI route index
http://localhost:8788/healthHealth check

In addition, the server automatically discovers and registers:

  1. Custom routes: Any routes in your server/api/ directory
  2. Integration routes: Timeback (+ more to come)

Custom API Routes

The dev server automatically discovers and serves routes from your server/api/ directory.

Routes are simple TypeScript files that export HTTP method handlers:

server/api/hello.ts
export async function GET(c: Context) {
    return c.json({ message: 'Hello from backend!' })
}

Learn More

See the Custom Routes Guide for complete documentation on creating and structuring routes.


Hot Reloading

The dev server automatically reloads when you:

  1. Add new routes: Creates new endpoints
  2. Modify existing routes: Updates handler logic
  3. Update config: Reloads integrations

No Manual Restart

Hot reload is enabled by default and watches for file changes automatically

What triggers a reload:

ChangeResult
Add server/api/new-route.tsRoute registered automatically
Edit server/api/existing.tsRoute handler updated
Update playcademy.config.jsConfig reloaded, integrations updated

What doesn't trigger a reload:

  1. Changes to frontend code (typically handled by your frontend framework)
  2. Changes to node_modules
  3. Changes outside the project directory

Server Options

Customize the dev server behavior:

Command
$ playcademy dev --port 9000$ playcademy dev --no-reload$ playcademy dev --no-logger
OptionDefaultDescription
-p, --port8788Backend server port
--no-reload(enabled)Disable hot module replacement
--no-logger(enabled)Disable HTTP request logging

Integrations in Development

Timeback Integration

Timeback Disabled (locally)

Timeback routes are disabled in local development.

This is temporary until a local Timeback environment is available.

Calls to Timeback endpoints return 503 with a helpful error message.

How to test out your Timeback integration:

  • Deploy your project to staging with playcademy deploy --env staging
  • Mock Timeback calls in your frontend code

Debugging

Request Logging

By default, all HTTP requests are logged to the console:

GET /api/hello 200 OK (12ms)
POST /api/validate-answer 200 OK (5ms)

Disable with --no-logger:

Command
$ playcademy dev --no-logger

Inspecting Routes

The dev server displays all registered routes on startup:

  /health                         GET
  /api/hello                      GET, POST
  /api/validate-answer            POST
  /api/users/:userId              GET

What's Next?

On this page