Quick Start

Get your first Nova API running in under 5 minutes. This guide walks you through creating a simple REST endpoint.

1. Create your project

You can create a Nova project manually (step-by-step) or use the Nova CLI to scaffold a project quickly. The manual approach is shown first and is perfectly fine — below it you'll find the CLI option (recommended for most users).

Manual (step-by-step)

Terminal bash

mkdir my-nova-app
cd my-nova-app
npm init -y
npm install @abrahambass/nova reflect-metadata zod
npm install -D typescript @types/node ts-node

Using the CLI (recommended)

Install the Nova CLI globally and scaffold a new project with a single command. The CLI will guide you through the next steps (it will show the instructions to cd into the folder, install dependencies, and run the dev server).

Terminal bash

# Install the Nova CLI globally
npm i -g @abrahambass/nova-cli
Terminal bash

# Create a new project using the CLI
nova create my-nova-app
Terminal (example CLI output) bash

Creating project 'my-nova-app'...
 Scaffolding project files
 Installing dependencies (optional)
Project created successfully!

Next steps:
  cd my-nova-app
  npm install
  npm run dev

2. Configure TypeScript

tsconfig.json json

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "commonjs",
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

3. Create your first controller

src/main.ts typescript

import 'reflect-metadata';
import { NovaFactory, Controller, Get, Post, Body, Path } from '@abrahambass/nova';
import { z } from 'zod';

const CreateTaskSchema = z.object({
  title: z.string().min(1),
  completed: z.boolean().default(false),
});

@Controller('/tasks')
class TaskController {
  @Get()
  async getAll() {
    return [{ id: 1, title: 'Learn Nova', completed: false }];
  }

  @Get('/:id')
  async getById(@Path('id') id: number) {
    return { id, title: 'Learn Nova', completed: false };
  }

  @Post()
  async create(@Body(CreateTaskSchema) data: z.infer<typeof CreateTaskSchema>) {
    return { id: 2, ...data };
  }
}

async function bootstrap() {
  const app = await NovaFactory.create();
  app.includeController(TaskController);
  await app.listen(3000);
}

bootstrap();

4. Run it

Terminal bash

npx ts-node src/main.ts

Your API is now running! Try it out:

Terminal bash

# GET all tasks
curl http://localhost:3000/tasks

# GET task by ID
curl http://localhost:3000/tasks/1

# POST create task
curl -X POST http://localhost:3000/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "New task"}'
🎉 Tip

Nova auto-validates the request body using your Zod schema. If validation fails, a detailed error response is returned automatically.