Two styles, one engine
Write controllers with decorators or with plain objects and functions. Both turn into the same definitions and behave identically.
A TypeScript framework for Node.js with modules, controllers and dependency injection. No reflect-metadata, no Express underneath.
npm create avi@latest my-api
cd my-api
npm install
npm run devimport { AviFactory, Controller, Get, Injectable, Module } from '@avijs/core';
@Injectable()
class UsersService {
findAll() {
return [{ id: 1, name: 'Ada' }];
}
}
@Controller('/users')
class UsersController {
static inject = [UsersService] as const;
constructor(private readonly users: UsersService) {}
@Get()
findAll() {
return this.users.findAll();
}
}
@Module({ controllers: [UsersController], providers: [UsersService] })
class AppModule {}
const app = await AviFactory.create(AppModule);
await app.listen(3000);import { createAvi, defineController } from '@avijs/core';
class UsersService {
findAll() {
return [{ id: 1, name: 'Ada' }];
}
}
const users = defineController({
prefix: '/users',
inject: [UsersService],
routes: (service) => [{ method: 'GET', path: '/', handler: () => service.findAll() }],
});
const app = createAvi().register({ providers: [UsersService], controllers: [users] });
await app.listen(3000);Avi.js is in early development (0.x): the API may still change between minor versions before 1.0.