Dwex Logo

Quick Start

Get started with Dwex in minutes

Prerequisites

Before you begin, ensure you have Bun installed on your system:

curl -fsSL https://bun.sh/install | bash

Verify installation:

bun --version
# Should output v1.0.0 or higher

Quick Start

Let your AI assistant (Claude, ChatGPT, etc.) set up a complete Dwex project for you. The copied prompt includes instructions to read the documentation and execute the setup commands using Bun.

The fastest way to get started is using the create-dwex CLI:

bun create dwex

This creates a new Dwex project with a recommended structure and configuration.

Manual Installation

If you prefer to set up your project manually:

# Create a new directory
mkdir my-app
cd my-app

# Initialize package.json
bun init -y

# Install Dwex packages
bun add @dwex/core @dwex/common reflect-metadata

TypeScript Configuration

Create a tsconfig.json file:

tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "declaration": true,
    "outDir": "./dist"
  },
  "include": ["src/**/*"]
}

Enable Decorators

Dwex relies on decorators and metadata reflection. Ensure your tsconfig.json includes:

tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Optional Packages

Enhance your application with additional modules:

JWT Authentication

bun add @dwex/jwt

Logging

bun add @dwex/logger

Project Structure

After installation, your project should look like this:

my-app/
├── src/
│   ├── app.module.ts
│   ├── app.controller.ts
│   └── main.ts
├── package.json
├── tsconfig.json
└── bun.lockb

Verify Installation

Create a simple src/main.ts to test your setup:

src/main.ts
import "reflect-metadata";
import { DwexFactory, Module, Controller, Get } from "@dwex/core";

@Controller()
class AppController {
  @Get()
  hello() {
    return "Hello, Dwex!";
  }
}

@Module({
  controllers: [AppController],
})
class AppModule {}

const app = await DwexFactory.create(AppModule);
await app.listen(9929);

Run your application:

bun run src/main.ts

Visit http://localhost:9929 - you should see "Hello, Dwex!"

Troubleshooting

"Cannot find module 'reflect-metadata'"

Make sure you import reflect-metadata at the top of your entry file:

import "reflect-metadata";

Decorator errors

Verify experimentalDecorators and emitDecoratorMetadata are enabled in your tsconfig.json.

Module resolution issues

Ensure your tsconfig.json uses:

tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "bundler"
  }
}

Next Steps