/application

AdonisJs application class to read app related data

Primary LanguageTypeScriptMIT LicenseMIT

Adonis application

circleci-image npm-image license-image

The application class for AdonisJs to know more about the environment and project structure of your AdonisJs applications.

Table of contents

Usage

Ideally you shouldn't be installing this module directly, since it is part of AdonisJs by default. However, installing module directly is helpful when testing AdonisJs specific addons.

npm i @adonisjs/application

# Yarn
yarn add @adonisjs/application

and then use it as follows:

import { Application } from '@adonisjs/application/build/standalone'
import { Ioc } from '@adonisjs/fold'

const app = new Application(
  __dirname,
  new Ioc(),
  require('./adonisrc.json'),
  require('./package.json'),
)

The constructor takes 4 arguments, which you can fake during tests.

Argument position Description
1 (appRoot) The application root
2 (ioc) Instance of IoC container
3 (rcContents) Contents of .adonisrc.json file. You can also provide an empty object
4 (pkgFile) Pass the contents of package.json file. Required to pull the app name, version and so on

rcParser

The application instance will parse the contents of .adonisrc.json file. However, if you need the parser, you can access and use it as follows.

import { rcParser } from '@adonisjs/application/build/standalone'
rcParser.parse(require('.adonisrc.json'))

API Docs

Following are the autogenerated files via Typedoc