...

/

Hello Adonis

Hello Adonis

Take a look at a simple AdonisJs application and learn about its folder structure.

First AdonisJs application

AdonisJs, like most frameworks, follows the MVC pattern and allows developers to write consistent, stable, and expressive code. To run an Adonis application on Educative, you don’t need to set anything up! All the code will run inside a special environment within the browser.

The following is a complete implementation of a basic application in AdonisJs. Press Run to see the output. Please be patient as the server is set up for you on the fly.

'use strict'

class ConvertEmptyStringsToNull {
  async handle ({ request }, next) {
    if (Object.keys(request.body).length) {
      request.body = Object.assign(
        ...Object.keys(request.body).map(key => ({
          [key]: request.body[key] !== '' ? request.body[key] : null
        }))
      )
    }

    await next()
  }
}

module.exports = ConvertEmptyStringsToNull

Folder

...