core
AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
Top Related Projects
Fast, unopinionated, minimalist web framework for node.
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript π
Expressive middleware for node.js using ES2017 async functions
Fast and low overhead web framework, for Node.js
The API and real-time application framework
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Quick Overview
AdonisJS is a full-stack web application framework for Node.js. It provides a robust set of tools and features for building modern web applications, including an ORM, authentication system, and a powerful CLI. AdonisJS follows the MVC pattern and is known for its developer-friendly API and excellent documentation.
Pros
- Robust and feature-rich framework with built-in tools for common web development tasks
- Strong emphasis on developer experience and productivity
- Excellent documentation and active community support
- Built-in security features and best practices
Cons
- Steeper learning curve compared to some other Node.js frameworks
- Opinionated structure may not suit all project types or developer preferences
- Smaller ecosystem compared to more established frameworks like Express.js
- Performance may be slightly lower than lightweight alternatives for simple applications
Code Examples
- Defining a route:
import Route from '@ioc:Adonis/Core/Route'
Route.get('/', async () => {
return { hello: 'world' }
})
- Creating a controller:
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class UsersController {
public async index({ response }: HttpContextContract) {
return response.json({ message: 'List of users' })
}
}
- Using the Lucid ORM:
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@column()
public email: string
@column()
public password: string
}
Getting Started
To get started with AdonisJS, follow these steps:
-
Install the AdonisJS CLI:
npm i -g @adonisjs/cli
-
Create a new project:
adonis new my-project cd my-project
-
Start the development server:
node ace serve --watch
Your AdonisJS application is now running at http://localhost:3333
.
Competitor Comparisons
Fast, unopinionated, minimalist web framework for node.
Pros of Express
- Lightweight and minimalist, allowing for greater flexibility and customization
- Extensive ecosystem with a wide range of middleware and plugins
- Simpler learning curve for developers familiar with Node.js
Cons of Express
- Requires more manual setup and configuration for common features
- Less opinionated, which can lead to inconsistent code structure across projects
- Lacks built-in support for modern JavaScript features and TypeScript
Code Comparison
Express:
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
})
AdonisJS:
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class HomeController {
public async index({ response }: HttpContextContract) {
return response.send('Hello World!')
}
}
Express provides a more straightforward approach with less boilerplate, while AdonisJS offers a more structured, class-based architecture with built-in TypeScript support. AdonisJS also includes features like dependency injection and a more robust routing system out of the box, which would require additional setup in Express.
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript π
Pros of Nest
- Stronger TypeScript integration and decorators for enhanced type safety
- More extensive ecosystem with a wider range of official packages
- Better support for microservices architecture out of the box
Cons of Nest
- Steeper learning curve due to its complexity and use of decorators
- Heavier framework with more boilerplate code required
- Can be overkill for smaller projects or simple APIs
Code Comparison
Nest:
@Controller('cats')
export class CatsController {
@Get()
findAll(): string {
return 'This action returns all cats';
}
}
AdonisJS:
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class CatsController {
public async index({ response }: HttpContextContract) {
return response.send('This action returns all cats')
}
}
Both frameworks use TypeScript and provide a structured approach to building web applications. Nest relies heavily on decorators and dependency injection, while AdonisJS offers a more straightforward, Laravel-inspired syntax. Nest's approach may be more familiar to Angular developers, while AdonisJS might feel more natural to developers coming from other MVC frameworks.
Expressive middleware for node.js using ES2017 async functions
Pros of Koa
- Lightweight and minimalist, allowing developers to add only what they need
- Excellent performance due to its small footprint
- Highly flexible and customizable with a wide range of middleware options
Cons of Koa
- Requires more setup and configuration for complex applications
- Less opinionated, which can lead to inconsistencies in large projects
- Smaller ecosystem compared to more comprehensive frameworks
Code Comparison
Koa:
const Koa = require('koa');
const app = new Koa();
app.use(async ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);
AdonisJS:
const { createServer } = require('@adonisjs/core/build/standalone')
createServer((app) => {
app.use(async ({ response }) => {
response.send('Hello World')
})
}).listen(3000)
Both examples show a simple "Hello World" server setup. Koa's approach is more straightforward, while AdonisJS provides a more structured setup with its createServer function. AdonisJS offers a more opinionated and feature-rich framework, whereas Koa focuses on simplicity and flexibility, allowing developers to build their stack from the ground up.
Fast and low overhead web framework, for Node.js
Pros of Fastify
- Extremely high performance and low overhead
- Extensive plugin ecosystem for easy extensibility
- Built-in support for JSON Schema validation
Cons of Fastify
- Steeper learning curve for beginners
- Less opinionated, requiring more setup for complex applications
- Smaller community compared to some other frameworks
Code Comparison
AdonisJS:
Route.get('/', async ({ view }) => {
return view.render('welcome')
})
Fastify:
fastify.get('/', async (request, reply) => {
return { hello: 'world' }
})
Key Differences
- AdonisJS provides a full-featured MVC framework, while Fastify focuses on being a lightweight and fast web framework
- AdonisJS includes an ORM (Lucid) out of the box, whereas Fastify requires additional plugins for database integration
- Fastify's plugin system allows for more granular control over features, while AdonisJS offers a more integrated experience
Use Cases
- Choose AdonisJS for rapid development of full-stack applications with built-in features
- Opt for Fastify when building high-performance microservices or APIs with specific requirements
Both frameworks have their strengths, and the choice depends on project needs, team expertise, and performance requirements.
The API and real-time application framework
Pros of Feathers
- More flexible and lightweight, allowing for easier integration with existing projects
- Supports real-time events out of the box, enabling easier development of real-time applications
- Offers a plugin system for extending functionality, providing greater customization options
Cons of Feathers
- Less opinionated structure, which may lead to inconsistencies in large projects
- Smaller ecosystem and community compared to AdonisJS
- Steeper learning curve for developers new to its concepts and architecture
Code Comparison
AdonisJS route definition:
Route.get('users', 'UsersController.index')
Route.post('users', 'UsersController.store')
Feathers service definition:
app.use('users', new UserService());
app.service('users').hooks({
before: { create: [validateUser] }
});
Both frameworks offer clean and concise ways to define routes or services, but AdonisJS follows a more traditional MVC structure, while Feathers uses a service-based approach. AdonisJS provides a more familiar syntax for developers coming from other MVC frameworks, whereas Feathers' approach may require some adjustment but offers flexibility in defining services and hooks.
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Pros of Strapi
- User-friendly content management system with a visual interface
- Highly customizable and extensible through plugins
- Built-in REST and GraphQL APIs for easy content delivery
Cons of Strapi
- Steeper learning curve for developers new to headless CMS
- More resource-intensive, especially for larger projects
- Less flexibility in database schema design compared to AdonisJS
Code Comparison
Strapi (Content Type Builder):
module.exports = {
attributes: {
title: {
type: 'string',
required: true
},
content: {
type: 'richtext'
}
}
};
AdonisJS (Model Definition):
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class Post extends BaseModel {
@column({ isPrimary: true })
public id: number
@column()
public title: string
@column()
public content: string
}
Both frameworks offer different approaches to defining data structures. Strapi uses a content type builder for a more visual approach, while AdonisJS relies on traditional model definitions with decorators.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
@adonisjs/core
Fullstack MVC framework for Node.js
AdonisJs is a fullstack Web framework with focus on ergonomics and speed . It takes care of much of the Web development hassles, offering you a clean and stable API to build Web apps and micro services.
Top Related Projects
Fast, unopinionated, minimalist web framework for node.
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript π
Expressive middleware for node.js using ES2017 async functions
Fast and low overhead web framework, for Node.js
The API and real-time application framework
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot