I create my own project with Adonisjs and this is my experience
Published: 2023-03-14 07:04:36

My name is Herman Christian and I am a web developer specializing in Nodejs technologies, in particular the Typescript language. Since 2020 I have been constantly training to measure and also to carry out projects on this language after finishing my studies in Telecommunication at a private university. In general, I am not interested in web development but before I turn to the development of office software with C++ and the Qt framework which is for me a revelation that pushes me to love programming; and also on the controls of computer networks by GNU/Linux distributions which is for me an extraordinary adventure. But during the confinement, I start looking for good work to make myself more financially independent but I had a hard time finding it. Until I realized that many clients are looking for web developers sooner than other areas in the digital market from where I start to research which programming languages exist today attract my attention and that I would work on the above to improve my performance and also my know-how in the field of Dev. I was testing a lot of programming languages such as PHP, Python, C# and Javascript but I had trouble understanding and having a taste for these languages, And that's when I came across a framework, that of Angular , which gave me a click in the heart like that of Qt of C++ this framework allowed me to discover a new programming language that of Typescript. At first it was difficult and complicated to understand this language but by dint of doing research and also constantly practicing by deepening my learning, to find what will be the best framework for me on this language and also advantageous for the development of my project, I have in order to find the right framework which is a revelation for me and it was the Adonis JS Framework.

**About the Adonisjs framework**
AdonisJS is a Node.js framework that is focused on developers’ ergonomics, stability, and speed. AdonisJS is written from the ground up with a strong principle and goals in mind to be a strong integrated system. It has an aspect similar to that of the PHP framework named Laravel but with a precision of data processing and also an extraordinary ergonomics. It was while watching a tutorial from a French youtuber Grafikart that I just discovered this framework and I have been working on it until now.
But unlike Laravel, this framework has some amazing stuff that I'm going to list for you below:
**A very rich Route manager**: which supports a grouped route, a subdomain route and also a prefix system which is so great.
```
// Handle GET request
Route.get('posts', async ({ view }) => {
  return view.render('posts/index')
})

// Handle POST request
Route.post('posts', async ({ request }) => {
  return request.body()
})

//Handle Grouped Route
Route
  .group(() => {
    Route.get('users', () => {})
    Route.post('users', () => {})
  })
  .prefix('api/v1')
  .middleware('auth')

// Static subdomain
Route
  .group(() => {
    Route.get('articles', () => {})
  })
  .domain('blog.adonisjs.com')

// Dynamic subdomain
Route
  .group(() => {
    Route.get('/', () => {})
  })
  .domain(':tenant.adonisjs.com')
```
**An easy-to-use controller**: Adonis controllers are the easiest to handle and also they help you to remove the inline route handlers to dedicated controller file

```
import Post from 'App/Models/Post'

export default class PostsController {
  public async index () {
    return Post.all()
  }

  public async store ({ request }) {
    return request.body()
  }
}

// Bind controller to the route
Route.get('posts', 'PostsController.index')
Route.post('posts', 'PostsController.store')
```
**A well-structured model**: Adonis models are a gift for me because they have a well-founded and well-typed structure so as not to lose on the nature of the data to be injected into it. The relationships between the different models are also effective.

```
import { DateTime } from 'luxon'
import { BaseModel, column, HasMany, hasMany } from '@ioc:Adonis/Lucid/Orm'
import Product from './Product'

export default class Categorie extends BaseModel {
  @column({ isPrimary: true })
  public id!: number

  @column()
  public name!: string
  
  @column()
  public description!: string | null
  
  @column()
  public slug!: string

  @column()
  public asset!: string
  
//Relationship between Categorie and Product
  @hasMany(() => Product)
  public products!: HasMany<typeof Product>
  
  @column.dateTime({ autoCreate: true })
  public createdAt!: DateTime

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  public updatedAt!: DateTime
}

```
**A well thought-out migration system**: when migrating to a database, in most frameworks, it requires you to use SQL queries to send data to the Database Management System, but now thanks to Adonis the latter is replaced by simple Typescript syntaxes.

```
import BaseSchema from '@ioc:Adonis/Lucid/Schema'

export default class extends BaseSchema {
  protected tableName = 'categories'

  public async up () {
    this.schema.createTable(this.tableName, (table) => {
      table.increments('id')
      table.string('name').notNullable()
      table.text('description').nullable()
      table.string('slug').notNullable()
      table.string('asset').nullable()
      table.timestamp('created_at', { useTz: true })
      table.timestamp('updated_at', { useTz: true })
    })
  }

  public async down () {
    this.schema.dropTable(this.tableName)
  }
}

```
And More than but there are the most functionality when he attract my love to this framework

**About my project**
The personal project that I have been developing for a year now is a project that serves to highlight a work of digital art created by artists and for artists in order to share and also to display a skill of a person according to talent. The thing I would like to do here is to present the style of each cartoonist according to the area of attraction such as eating, illustration, game character or other, by highlighting the portfolio and being seen by the people who matter in the industry, all in a fast and elegant way. Images, videos, short clips, 3D scenes from Marmoset or Sketchfab, 360° panoramas... the possibilities are endless. Show your works and production experiences to the world.
It is not yet online at the moment for lack of investment but I want to launch it here shortly, for the sake that it will be fast and I could show you the real result of the project, on the other hand I join the link to which you can contribute for the development and also I am looking for a collaborator if you agree.
In general, I develop this project for two very distinct reasons:
**The first**, that I like the drawings and all that surrounds it, and I would like to share my skills and my know-how in the field
**The second**, I would like to add in this project a functionality which serves to highlight certain work in order to monetize the project and also a work in particular by using NFT technology but on the latter I do not yet master what slows down the production of the project.

![screenshot of the result on my PC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1606j7rxcj838m41fab.png)
So if anyone is interested, all your contributions will be an honor for me since I will share with you all the source code of the latter.
Thank you in advance for your cooperation and kindness.
[link in the project](https://github.com/Herman-Riah19/TryInc)