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 | bashVerify installation:
bun --version
# Should output v1.0.0 or higherQuick Start
The fastest way to get started is using the create-dwex CLI:
bun create dwex my-app
cd my-app
bun installThis 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-metadataTypeScript Configuration
Create a tsconfig.json file:
{
"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:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}Optional Packages
Enhance your application with additional modules:
JWT Authentication
bun add @dwex/jwtLogging
bun add @dwex/loggerProject 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.lockbVerify Installation
Create a simple src/main.ts to test your setup:
import "reflect-metadata";
import { DwexFactory, Module, Controller, Get } from "@dwex/core";
@Controller()
class AppController {
@Get()
hello() {
return "Hello, Dwex!";
}
}
@Module({
controllers: [AppController],
})
class AppModule {}
async function bootstrap() {
const app = await DwexFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();Run your application:
bun run src/main.tsVisit http://localhost:3000 - 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:
{
"compilerOptions": {
"moduleResolution": "bundler"
}
}