Showing preview only (700K chars total). Download the full file or copy to clipboard to get everything.
Repository: adonisjs/core
Branch: 7.x
Commit: a28022d699b9
Files: 226
Total size: 648.3 KB
Directory structure:
gitextract_zov6uehz/
├── .editorconfig
├── .github/
│ └── workflows/
│ ├── checks.yml
│ ├── labels.yml
│ ├── release.yml
│ ├── stale.yml
│ └── test.yml
├── .gitignore
├── .npmrc
├── .prettierignore
├── LICENSE.md
├── README.md
├── bin/
│ └── test.ts
├── commands/
│ ├── add.ts
│ ├── build.ts
│ ├── configure.ts
│ ├── eject.ts
│ ├── env/
│ │ └── add.ts
│ ├── generate_key.ts
│ ├── inspect_rcfile.ts
│ ├── list/
│ │ └── routes.ts
│ ├── make/
│ │ ├── command.ts
│ │ ├── controller.ts
│ │ ├── event.ts
│ │ ├── exception.ts
│ │ ├── listener.ts
│ │ ├── middleware.ts
│ │ ├── preload.ts
│ │ ├── provider.ts
│ │ ├── service.ts
│ │ ├── test.ts
│ │ ├── transformer.ts
│ │ ├── validator.ts
│ │ └── view.ts
│ ├── repl.ts
│ ├── serve.ts
│ └── test.ts
├── eslint.config.js
├── factories/
│ ├── app.ts
│ ├── bodyparser.ts
│ ├── core/
│ │ ├── ace.ts
│ │ ├── ignitor.ts
│ │ ├── main.ts
│ │ └── test_utils.ts
│ ├── encryption.ts
│ ├── events.ts
│ ├── hash.ts
│ ├── http.ts
│ ├── logger.ts
│ └── stubs.ts
├── funding.json
├── index.ts
├── modules/
│ ├── ace/
│ │ ├── codemods.ts
│ │ ├── commands.ts
│ │ ├── create_kernel.ts
│ │ ├── kernel.ts
│ │ └── main.ts
│ ├── app.ts
│ ├── bodyparser/
│ │ ├── bodyparser_middleware.ts
│ │ └── main.ts
│ ├── config.ts
│ ├── container.ts
│ ├── dumper/
│ │ ├── define_config.ts
│ │ ├── dumper.ts
│ │ ├── errors.ts
│ │ ├── main.ts
│ │ └── plugins/
│ │ └── edge.ts
│ ├── encryption/
│ │ ├── define_config.ts
│ │ ├── drivers/
│ │ │ ├── aes_256_cbc.ts
│ │ │ ├── aes_256_gcm.ts
│ │ │ ├── aes_siv.ts
│ │ │ ├── chacha20_poly1305.ts
│ │ │ └── legacy.ts
│ │ ├── errors.ts
│ │ └── main.ts
│ ├── env/
│ │ ├── editor.ts
│ │ └── main.ts
│ ├── events.ts
│ ├── hash/
│ │ ├── define_config.ts
│ │ ├── drivers/
│ │ │ ├── argon.ts
│ │ │ ├── bcrypt.ts
│ │ │ └── scrypt.ts
│ │ ├── main.ts
│ │ └── phc_formatter.ts
│ ├── health.ts
│ ├── http/
│ │ ├── helpers.ts
│ │ ├── main.ts
│ │ ├── request_validator.ts
│ │ └── url_builder_client.ts
│ ├── logger.ts
│ ├── repl.ts
│ └── transformers/
│ └── main.ts
├── package.json
├── providers/
│ ├── app_provider.ts
│ ├── edge_provider.ts
│ ├── hash_provider.ts
│ ├── repl_provider.ts
│ └── vinejs_provider.ts
├── services/
│ ├── ace.ts
│ ├── app.ts
│ ├── config.ts
│ ├── dumper.ts
│ ├── emitter.ts
│ ├── encryption.ts
│ ├── hash.ts
│ ├── logger.ts
│ ├── repl.ts
│ ├── router.ts
│ ├── server.ts
│ ├── test_utils.ts
│ └── url_builder.ts
├── src/
│ ├── assembler_hooks/
│ │ └── index_entities.ts
│ ├── cli_formatters/
│ │ └── routes_list.ts
│ ├── config_provider.ts
│ ├── debug.ts
│ ├── exceptions.ts
│ ├── helpers/
│ │ ├── assert.ts
│ │ ├── http.ts
│ │ ├── is.ts
│ │ ├── main.ts
│ │ ├── string.ts
│ │ ├── types.ts
│ │ └── verification_token.ts
│ ├── ignitor/
│ │ ├── ace.ts
│ │ ├── http.ts
│ │ ├── main.ts
│ │ └── test.ts
│ ├── test_utils/
│ │ ├── http.ts
│ │ └── main.ts
│ ├── types.ts
│ ├── utils.ts
│ └── vine.ts
├── stubs/
│ ├── main.ts
│ └── make/
│ ├── command/
│ │ └── main.stub
│ ├── controller/
│ │ ├── actions.stub
│ │ ├── api.stub
│ │ ├── main.stub
│ │ └── resource.stub
│ ├── event/
│ │ └── main.stub
│ ├── exception/
│ │ └── main.stub
│ ├── health/
│ │ ├── controller.stub
│ │ └── main.stub
│ ├── listener/
│ │ ├── for_event.stub
│ │ └── main.stub
│ ├── middleware/
│ │ └── main.stub
│ ├── preload/
│ │ └── main.stub
│ ├── provider/
│ │ └── main.stub
│ ├── service/
│ │ └── main.stub
│ ├── test/
│ │ └── main.stub
│ ├── transformer/
│ │ └── main.stub
│ ├── validator/
│ │ ├── main.stub
│ │ └── resource.stub
│ └── view/
│ └── main.stub
├── tests/
│ ├── ace/
│ │ ├── base_command.spec.ts
│ │ ├── codemods.spec.ts
│ │ └── kernel.spec.ts
│ ├── bindings/
│ │ ├── edge.spec.ts
│ │ ├── repl.spec.ts
│ │ └── vinejs.spec.ts
│ ├── cli_formatters/
│ │ └── routes_list.spec.ts
│ ├── commands/
│ │ ├── add.spec.ts
│ │ ├── build.spec.ts
│ │ ├── configure.spec.ts
│ │ ├── eject.spec.ts
│ │ ├── env_add.spec.ts
│ │ ├── generate_key.spec.ts
│ │ ├── inspect_rcfile.spec.ts
│ │ ├── make_command.spec.ts
│ │ ├── make_controller.spec.ts
│ │ ├── make_event.spec.ts
│ │ ├── make_exception.spec.ts
│ │ ├── make_listener.spec.ts
│ │ ├── make_middleware.spec.ts
│ │ ├── make_preload.spec.ts
│ │ ├── make_provider.spec.ts
│ │ ├── make_service.spec.ts
│ │ ├── make_test.spec.ts
│ │ ├── make_transformer.spec.ts
│ │ ├── make_validator.spec.ts
│ │ ├── make_view.spec.ts
│ │ ├── serve.spec.ts
│ │ └── test.spec.ts
│ ├── dumper/
│ │ └── dumper.spec.ts
│ ├── encryption/
│ │ └── legacy.spec.ts
│ ├── hash.spec.ts
│ ├── helpers.spec.ts
│ ├── helpers.ts
│ ├── ignitor/
│ │ ├── ace_process.spec.ts
│ │ ├── http_server_process.spec.ts
│ │ ├── main.spec.ts
│ │ └── test_process.spec.ts
│ ├── index_generator.spec.ts
│ ├── pretty_print_error.spec.ts
│ ├── providers.spec.ts
│ ├── request_validator.spec.ts
│ ├── stubs/
│ │ ├── make_command.spec.ts
│ │ ├── make_controller.spec.ts
│ │ ├── make_event.spec.ts
│ │ ├── make_exception.spec.ts
│ │ ├── make_listener.spec.ts
│ │ ├── make_middleware.spec.ts
│ │ ├── make_prldfile.spec.ts
│ │ ├── make_provider.spec.ts
│ │ ├── make_service.spec.ts
│ │ ├── make_test.spec.ts
│ │ ├── make_validator.spec.ts
│ │ └── make_view.spec.ts
│ ├── test_utils/
│ │ └── http.spec.ts
│ └── verification_token.spec.ts
├── toolkit/
│ ├── commands/
│ │ └── index_commands.ts
│ └── main.ts
├── tsconfig.json
├── typedoc.json
└── types/
├── ace.ts
├── app.ts
├── bodyparser.ts
├── common.ts
├── container.ts
├── encryption.ts
├── events.ts
├── hash.ts
├── health.ts
├── helpers.ts
├── http.ts
├── logger.ts
├── repl.ts
└── transformers.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
# http://editorconfig.org
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.json]
insert_final_newline = ignore
[**.min.js]
indent_style = ignore
insert_final_newline = ignore
[MakeFile]
indent_style = space
[*.md]
trim_trailing_whitespace = false
================================================
FILE: .github/workflows/checks.yml
================================================
name: checks
on:
- push
- pull_request
- workflow_call
jobs:
test:
uses: adonisjs/core/.github/workflows/test.yml@7.x
with:
install-pnpm: true
lint:
uses: adonisjs/.github/.github/workflows/lint.yml@main
typecheck:
uses: adonisjs/.github/.github/workflows/typecheck.yml@main
================================================
FILE: .github/workflows/labels.yml
================================================
name: Sync labels
on:
workflow_dispatch:
permissions:
issues: write
jobs:
labels:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EndBug/label-sync@v2
with:
config-file: 'https://raw.githubusercontent.com/thetutlage/static/main/labels.yml'
delete-other-labels: true
token: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/release.yml
================================================
name: release
on: workflow_dispatch
permissions:
contents: write
id-token: write
jobs:
checks:
uses: ./.github/workflows/checks.yml
release:
needs: checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Init npm config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npm install
- run: npm run release -- --ci
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
================================================
FILE: .github/workflows/stale.yml
================================================
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 0 * * *'
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still need help on this issue'
stale-pr-message: 'This pull request has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still intend to submit this pull request'
close-issue-message: 'This issue has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still need help on this issue'
close-pr-message: 'This pull request has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still intend to submit this pull request'
exempt-issue-labels: 'Status: On Hold,Pinned'
days-before-stale: 21
days-before-close: 5
================================================
FILE: .github/workflows/test.yml
================================================
on:
workflow_call:
inputs:
disable-windows:
description: Disable running tests on Windows
type: boolean
default: false
required: false
install-pnpm:
description: Install pnpm before running tests
type: boolean
default: false
required: false
jobs:
test_linux:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['lts/krypton', 'latest']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
if: ${{ inputs.install-pnpm }}
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
test_windows:
if: ${{ !inputs.disable-windows }}
runs-on: windows-latest
strategy:
matrix:
node-version: ['lts/krypton', 'latest']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
if: ${{ inputs.install-pnpm }}
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
================================================
FILE: .gitignore
================================================
node_modules
coverage
.DS_STORE
.nyc_output
.idea
.vscode/
*.sublime-project
*.sublime-workspace
*.log
build
dist
yarn.lock
shrinkwrap.yaml
package-lock.json
test/__app
.env
backup
================================================
FILE: .npmrc
================================================
package-lock=false
================================================
FILE: .prettierignore
================================================
build
docs
coverage
================================================
FILE: LICENSE.md
================================================
# The MIT License
Copyright 2022 Harminder Virk, contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
# @adonisjs/core
**Featured sponsors**
<table>
<tr>
<td>
<a href="https://route4me.com/?utm_source=adonisjs.com">
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/route4me.jpg" />
</a>
</td>
<td>
<a href="https://ezycourse.com/?utm_source=adonisjs.com">
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/ezycourse.jpg" />
</a>
</td>
</tr>
<tr>
<td>
<a href="https://meteor.software/g6h?utm_source=adonisjs.com">
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/galaxy.jpg" />
</a>
</td>
<td>
<a href="https://www.testmuai.com/?utm_source=adonisjs.com">
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/testmu.jpg" />
</a>
</td>
</tr>
<tr>
<td>
<a href="https://relancer.com/?utm_source=adonisjs.com">
<img src="https://raw.githubusercontent.com/thetutlage/static/refs/heads/main/featured_sponsors/logos/relancer.jpg" />
</a>
</td>
<td>
</td>
</tr>
</table>

<hr>
<br />
<div align="center">
<h3>Fullstack MVC framework for Node.js</h3>
<p>AdonisJs is a fullstack Web framework with focus on <strong> ergonomics and speed </strong>. It takes care of much of the Web development hassles, offering you a clean and stable API to build Web apps and micro services.</p>
</div>
<br />
<div align="center">
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
</div>
<div align="center">
<h3>
<a href="https://adonisjs.com">
Website
</a>
<span> | </span>
<a href="https://docs.adonisjs.com">
Guides
</a>
<span> | </span>
<a href="https://github.com/adonisjs/.github/blob/main/docs/CONTRIBUTING.md">
Contributing
</a>
</h3>
</div>
<div align="center">
<sub>Built with ❤︎ by <a href="https://github.com/thetutlage">Harminder Virk</a>
</div>
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/core/checks.yml?label=Tests&style=for-the-badge
[gh-workflow-url]: https://github.com/adonisjs/core/actions/workflows/checks.yml 'Github action'
[npm-image]: https://img.shields.io/npm/v/@adonisjs/core/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://www.npmjs.com/package/@adonisjs/core/v/latest 'npm'
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
[license-url]: LICENSE.md
[license-image]: https://img.shields.io/github/license/adonisjs/adonis-framework?style=for-the-badge
================================================
FILE: bin/test.ts
================================================
import { assert } from '@japa/assert'
import { snapshot } from '@japa/snapshot'
import { fileSystem } from '@japa/file-system'
import { expectTypeOf } from '@japa/expect-type'
import { processCLIArgs, configure, run } from '@japa/runner'
/*
|--------------------------------------------------------------------------
| Configure tests
|--------------------------------------------------------------------------
|
| The configure method accepts the configuration to configure the Japa
| tests runner.
|
| The first method call "processCLIArgs" process the command line arguments
| and turns them into a config object. Using this method is not mandatory.
|
| Please consult japa.dev/runner-config for the config docs.
*/
processCLIArgs(process.argv.slice(2))
configure({
files: ['tests/**/*.spec.ts'],
plugins: [assert(), expectTypeOf(), fileSystem(), snapshot()],
})
/*
|--------------------------------------------------------------------------
| Run tests
|--------------------------------------------------------------------------
|
| The following "run" method is required to execute all the tests.
|
*/
run()
================================================
FILE: commands/add.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { prettyPrintError } from '../index.ts'
import { type CommandOptions } from '../types/ace.ts'
import { args, BaseCommand, flags } from '../modules/ace/main.ts'
import { type SupportedPackageManager } from '@adonisjs/assembler/types'
/**
* The install command is used to `npm install` and `node ace configure` one or more packages
* in one go.
*
* @example
* ```
* ace add @adonisjs/lucid
* ace add @adonisjs/lucid @adonisjs/auth @adonisjs/session
* ace add @adonisjs/session --dev
* ace add vinejs --force
* ace add edge --package-manager=pnpm
* ```
*/
export default class Add extends BaseCommand {
/**
* The command name
*/
static commandName = 'add'
/**
* The command description
*/
static description =
'Install and configure one or more AdonisJS packages. Runs npm install followed by the package configure hook'
static help = [
'Use this command instead of manually running npm install + configure separately.',
'Accepts shorthand names: "vinejs" for @vinejs/vine, "edge" for edge.js.',
'```',
'{{ binaryName }} add @adonisjs/lucid',
'{{ binaryName }} add @adonisjs/auth @adonisjs/session',
'```',
]
/**
* Command options configuration
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Package names to install and configure
*/
@args.spread({ description: 'Package names to install and configure', required: true })
declare names: string[]
/**
* Display logs in verbose mode
*/
@flags.boolean({ description: 'Display logs in verbose mode' })
declare verbose?: boolean
/**
* Define the package manager you want to use
*/
@flags.string({ description: 'Define the package manager you want to use' })
declare packageManager?: SupportedPackageManager
/**
* Should we install the package as a dev dependency
*/
@flags.boolean({ description: 'Should we install the package as a dev dependency', alias: 'D' })
declare dev?: boolean
/**
* Forcefully overwrite existing files
*/
@flags.boolean({ description: 'Forcefully overwrite existing files' })
declare force?: boolean
/**
* Resolve the npm package name from the user-provided name
*/
#resolveNpmPackageName(name: string): string {
if (name === 'vinejs') {
return '@vinejs/vine'
}
if (name === 'edge') {
return 'edge.js'
}
return name
}
/**
* Configure the package by delegating the work to the `node ace configure` command
*/
async #configurePackage(packageName: string) {
const flagValueArray = this.parsed.unknownFlags
.filter((flag) => !!this.parsed.flags[flag])
.map((flag) => [`--${flag}`, this.parsed.flags[flag].toString()])
const configureArgs = [
packageName,
this.force ? '--force' : undefined,
this.verbose ? '--verbose' : undefined,
...flagValueArray.flat(),
].filter(Boolean) as string[]
return await this.kernel.exec('configure', configureArgs)
}
/**
* Run method is invoked by ace automatically
*/
async run() {
const packages = this.names.map((name) => ({
name,
npmName: this.#resolveNpmPackageName(name),
}))
/**
* Install all packages
*/
const codemods = await this.createCodemods()
codemods.verboseInstallOutput = !!this.verbose
const packagesWereInstalled = await codemods.installPackages(
packages.map((pkg) => ({ name: pkg.npmName, isDevDependency: !!this.dev })),
this.packageManager
)
if (!packagesWereInstalled) {
return
}
/**
* Configure each package sequentially
*/
const succeeded: string[] = []
const failed: { name: string; error?: Error }[] = []
for (const pkg of packages) {
const { exitCode, error } = await this.#configurePackage(pkg.name)
if (exitCode === 0) {
succeeded.push(pkg.name)
} else {
failed.push({ name: pkg.name, error })
}
}
/**
* Report results
*/
if (succeeded.length > 0) {
const names = succeeded.map((name) => this.colors.green(name)).join(', ')
this.logger.success(`Installed and configured ${names}`)
}
if (failed.length > 0) {
this.exitCode = 1
for (const pkg of failed) {
this.logger.error(`Unable to configure ${this.colors.green(pkg.name)}`)
if (pkg.error) {
await prettyPrintError(pkg.error.cause || pkg.error)
}
}
}
}
}
================================================
FILE: commands/build.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BaseCommand, flags } from '../modules/ace/main.ts'
import { importAssembler, importTypeScript } from '../src/utils.ts'
/**
* Create the production build by compiling TypeScript source and the
* frontend assets
*
* @example
* ```
* ace build
* ace build --ignore-ts-errors
* ace build --package-manager=pnpm
* ```
*/
export default class Build extends BaseCommand {
/**
* The command name
*/
static commandName = 'build'
/**
* The command description
*/
static description =
'Build application for production by compiling frontend assets and TypeScript source to JavaScript'
/**
* Help text for the command
*/
static help = [
'Create the production build using the following command.',
'```',
'{{ binaryName }} build',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
'You may pass vite CLI args using the --assets-args command line flag.',
'```',
'{{ binaryName }} build --assets-args="--debug --base=/public"',
'```',
]
/**
* Ignore TypeScript errors and continue with the build process
*/
@flags.boolean({ description: 'Ignore TypeScript errors and continue with the build process' })
declare ignoreTsErrors?: boolean
/**
* Define the package manager to copy the appropriate lock file
*/
@flags.string({
description: 'Define the package manager to copy the appropriate lock file',
})
declare packageManager?: 'npm' | 'pnpm' | 'yarn' | 'yarn@berry' | 'bun'
/**
* Log a development dependency is missing
*
* @param dependency - The name of the missing dependency
*/
#logMissingDevelopmentDependency(dependency: string) {
this.logger.error(
[
`Cannot find package "${dependency}"`,
'',
`The "${dependency}" package is a development dependency and therefore you should use the build command with development dependencies installed.`,
'',
'If you are using the build command inside a CI or with a deployment platform, make sure the NODE_ENV is set to "development"',
].join('\n')
)
}
/**
* Build application
*/
async run() {
const assembler = await importAssembler(this.app)
if (!assembler) {
this.#logMissingDevelopmentDependency('@adonisjs/assembler')
this.exitCode = 1
return
}
const ts = await importTypeScript(this.app)
if (!ts) {
this.#logMissingDevelopmentDependency('typescript')
this.exitCode = 1
return
}
const bundler = new assembler.Bundler(this.app.appRoot, ts, {
metaFiles: this.app.rcFile.metaFiles,
hooks: this.app.rcFile.hooks,
})
/**
* Share command logger with assembler, so that CLI flags like --no-ansi has
* similar impact for assembler logs as well.
*/
bundler.ui.logger = this.logger
/**
* Bundle project for production
*/
const stopOnError = this.ignoreTsErrors === true ? false : true
const builtSuccessfully = await bundler.bundle(stopOnError, this.packageManager)
if (!builtSuccessfully) {
this.exitCode = 1
}
}
}
================================================
FILE: commands/configure.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { RuntimeException } from '@poppinss/utils/exception'
import { stubsRoot } from '../stubs/main.ts'
import type { CommandOptions } from '../types/ace.ts'
import { args, BaseCommand, flags } from '../modules/ace/main.ts'
/**
* Command to configure packages after installation by running their configuration hooks.
* Supports built-in configurations for VineJS, Edge, and health checks, or can execute
* custom configure functions exported by packages.
*
* @example
* ```
* ace configure @adonisjs/lucid
* ace configure vinejs
* ace configure edge
* ace configure health_checks
* ace configure @adonisjs/auth --force --verbose
* ```
*/
export default class Configure extends BaseCommand {
/**
* The command name
*/
static commandName = 'configure'
/**
* The command description
*/
static description =
'Run the configure hook of an already-installed package. Use "add" command instead to both install and configure in one step'
/**
* Command options configuration.
* Allows unknown flags to be passed to package configure functions.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Expose all flags from the protected property "parsed" for access by package configure functions
*/
get parsedFlags() {
return this.parsed.flags
}
/**
* Expose all arguments from the protected property "parsed" for access by package configure functions
*/
get parsedArgs() {
return this.parsed._
}
/**
* Name of the package to configure
*/
@args.string({ description: 'Package name' })
declare name: string
/**
* Enable verbose logging during package installation and configuration
*/
@flags.boolean({ description: 'Display logs in verbose mode', alias: 'v' })
declare verbose?: boolean
/**
* Forcefully overwrite existing files during configuration
*/
@flags.boolean({ description: 'Forcefully overwrite existing files', alias: 'f' })
declare force?: boolean
/**
* The root directory path of the package's stubs.
* Set automatically when the package exports a stubsRoot property.
*/
declare stubsRoot: string
/**
* Import and return the main exports of a package.
* Returns null if the package is not found, rethrows other errors.
*
* @param packageName - The name of the package to import
* @returns The package exports or null if not found
*/
async #getPackageSource(packageName: string) {
try {
const packageExports = await this.app.import(packageName)
return packageExports
} catch (error) {
if (
(error.code && error.code === 'ERR_MODULE_NOT_FOUND') ||
error.message.startsWith('Cannot find module')
) {
return null
}
throw error
}
}
/**
* Configure VineJS validation library by registering its provider in the RC file
*/
async #configureVineJS() {
const codemods = await this.createCodemods()
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/core/providers/vinejs_provider')
})
}
/**
* Configure Edge template engine by registering its provider and adding view meta files
*/
async #configureEdge() {
const codemods = await this.createCodemods()
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider('@adonisjs/core/providers/edge_provider')
rcFile.addMetaFile('resources/views/**/*.edge', false)
})
}
/**
* Configure health checks feature by generating the main health file and controller
*/
async #configureHealthChecks() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(stubsRoot, 'make/health/main.stub', {
flags: this.parsed.flags,
entity: this.app.generators.createEntity('health'),
})
await codemods.makeUsingStub(stubsRoot, 'make/health/controller.stub', {
flags: this.parsed.flags,
entity: this.app.generators.createEntity('health_checks'),
})
}
/**
* Create a codemods instance configured with command options.
* Sets overwrite and verbose flags based on command arguments.
*/
async createCodemods() {
const codemods = await super.createCodemods()
codemods.overwriteExisting = this.force === true
codemods.verboseInstallOutput = this.verbose === true
return codemods
}
/**
* Execute the configure command. Handles built-in configurations for VineJS, Edge,
* and health checks, or imports and executes the configure function from the specified package.
*/
async run() {
if (this.name === 'vinejs') {
return this.#configureVineJS()
}
if (this.name === 'edge') {
return this.#configureEdge()
}
if (this.name === 'health_checks') {
return this.#configureHealthChecks()
}
const packageExports = await this.#getPackageSource(this.name)
if (!packageExports) {
this.logger.error(`Cannot find module "${this.name}". Make sure to install it`)
this.exitCode = 1
return
}
/**
* Warn, there are not instructions to run
*/
if (!packageExports.configure) {
this.logger.warning(
`Cannot configure module "${this.name}". The module does not export the configure hook`
)
return
}
/**
* Set stubsRoot property when package exports it
*/
if (packageExports.stubsRoot) {
this.stubsRoot = packageExports.stubsRoot
}
/**
* Run instructions
*/
try {
await packageExports.configure(this)
} catch (error) {
throw new RuntimeException(`Unable to configure package "${this.name}"`, {
cause: error,
})
}
}
}
================================================
FILE: commands/eject.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { args, BaseCommand, flags } from '../modules/ace/main.ts'
import stringHelpers from '../src/helpers/string.ts'
/**
* Command to eject scaffolding stubs from packages to your application root.
* This allows you to customize templates used by make commands and other
* code generation features by copying them to your local application.
*
* @example
* ```
* ace eject make/controller
* ace eject make/controller --pkg=@adonisjs/lucid
* ace eject stubs/
* ```
*/
export default class Eject extends BaseCommand {
/**
* The command name
*/
static commandName = 'eject'
/**
* The command description
*/
static description =
'Copy scaffolding stubs from a package to your application for customization. Stubs are templates used by make:* commands'
/**
* Path to the stubs directory or a single stub file to eject
*/
@args.string({ description: 'Path to the stubs directory or a single stub file' })
declare stubPath: string
/**
* Package name to search for stubs. Defaults to @adonisjs/core
*/
@flags.string({
description: 'Mention package name for searching stubs',
default: '@adonisjs/core',
})
declare pkg: string
/**
* Execute the command to eject stubs from the specified package.
* Copies the stubs to the application root and logs success messages
* for each ejected file.
*/
async run() {
const stubs = await this.app.stubs.create()
const copied = await stubs.copy(this.stubPath, {
pkg: this.pkg,
})
copied.forEach((stubPath) => {
this.logger.success(`eject ${stringHelpers.toUnixSlash(this.app.relativePath(stubPath))}`)
})
}
}
================================================
FILE: commands/env/add.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { type CommandOptions } from '../../types/ace.ts'
import stringHelpers from '../../src/helpers/string.ts'
import { args, BaseCommand, flags } from '../../modules/ace/main.ts'
const ALLOWED_TYPES = ['string', 'boolean', 'number', 'enum'] as const
type AllowedTypes = (typeof ALLOWED_TYPES)[number]
/**
* Command to add a new environment variable to the application.
* Updates .env, .env.example, and start/env.ts files with the new variable,
* including appropriate validation schema based on the variable type.
*
* @example
* ```
* ace env:add
* ace env:add DATABASE_URL postgres://localhost:5432/mydb
* ace env:add API_KEY secret --type=string
* ace env:add PORT 3333 --type=number
* ace env:add DEBUG true --type=boolean
* ace env:add LOG_LEVEL info --type=enum --enum-values=debug,info,warn,error
* ```
*/
export default class EnvAdd extends BaseCommand {
/**
* The command name
*/
static commandName = 'env:add'
/**
* The command description
*/
static description =
'Add a new environment variable to .env, .env.example, and its validation rule to start/env.ts'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Environment variable name (will be converted to SCREAMING_SNAKE_CASE)
*/
@args.string({
description: 'Variable name. Will be converted to screaming snake case',
required: false,
})
declare name: string
/**
* Environment variable value
*/
@args.string({ description: 'Variable value', required: false })
declare value: string
/**
* Data type of the environment variable (string, boolean, number, enum)
*/
@flags.string({ description: 'Type of the variable' })
declare type: AllowedTypes
/**
* Allowed values for enum type variables
*/
@flags.array({
description: 'Allowed values for the enum type in a comma-separated list',
default: [''],
required: false,
})
declare enumValues: string[]
/**
* Validate that the provided type is one of the allowed types.
*
* @returns True if the type is valid, false otherwise
*/
#isTypeFlagValid() {
return ALLOWED_TYPES.includes(this.type)
}
/**
* Execute the command to add a new environment variable.
* Prompts for missing values, validates inputs, and updates all relevant files.
*/
async run() {
/**
* Prompt for missing name
*/
if (!this.name) {
this.name = await this.prompt.ask('Enter the variable name', {
validate: (value) => !!value,
format: (value) => stringHelpers.snakeCase(value).toUpperCase(),
})
}
/**
* Prompt for missing value
*/
if (!this.value) {
this.value = await this.prompt.ask('Enter the variable value')
}
/**
* Prompt for missing type
*/
if (!this.type) {
this.type = await this.prompt.choice('Select the variable type', ALLOWED_TYPES)
}
/**
* Prompt for missing enum values if the selected env type is `enum`
*/
if (this.type === 'enum' && !this.enumValues) {
this.enumValues = await this.prompt.ask('Enter the enum values separated by a comma', {
result: (value) => value.split(',').map((one) => one.trim()),
})
}
/**
* Validate inputs
*/
if (!this.#isTypeFlagValid()) {
this.logger.error(`Invalid type "${this.type}". Must be one of ${ALLOWED_TYPES.join(', ')}`)
return
}
/**
* Add the environment variable to the `.env` and `.env.example` files
*/
const codemods = await this.createCodemods()
const transformedName = stringHelpers.snakeCase(this.name).toUpperCase()
await codemods.defineEnvVariables(
{ [transformedName]: this.value },
{ omitFromExample: [transformedName] }
)
/**
* Add the environment variable to the `start/env.ts` file
*/
const validation = {
string: 'Env.schema.string()',
number: 'Env.schema.number()',
boolean: 'Env.schema.boolean()',
enum: `Env.schema.enum(['${this.enumValues.join("','")}'] as const)`,
}[this.type]
await codemods.defineEnvValidations({ variables: { [transformedName]: validation } })
this.logger.success('Environment variable added successfully')
}
}
================================================
FILE: commands/generate_key.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import string from '@poppinss/utils/string'
import { EnvEditor } from '@adonisjs/env/editor'
import { BaseCommand, flags } from '../modules/ace/main.ts'
/**
* The generate key command is used to generate the app key
* and write it inside the .env file.
*
* @example
* ```
* ace generate:key
* ace generate:key --show
* ace generate:key --force
* ```
*/
export default class GenerateKey extends BaseCommand {
/**
* The command name
*/
static commandName = 'generate:key'
/**
* The command description
*/
static description =
'Generate a cryptographically secure APP_KEY and write it to the .env file. Use --show to print without writing'
/**
* Display the key on the terminal, instead of writing it to .env file
*/
@flags.boolean({
description: 'Display the key on the terminal, instead of writing it to .env file',
})
declare show: boolean
/**
* Force update .env file in production environment
*/
@flags.boolean({
description: 'Force update .env file in production environment',
})
declare force: boolean
async run() {
let writeToFile = process.env.NODE_ENV !== 'production'
if (this.force) {
writeToFile = true
}
if (this.show) {
writeToFile = false
}
const secureKey = string.random(32)
if (writeToFile) {
const editor = await EnvEditor.create(this.app.appRoot)
editor.add('APP_KEY', secureKey, true)
await editor.save()
this.logger.action('add APP_KEY to .env').succeeded()
} else {
this.logger.log(`APP_KEY = ${secureKey}`)
}
}
}
================================================
FILE: commands/inspect_rcfile.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BaseCommand } from '../modules/ace/main.ts'
/**
* Command to inspect and display the AdonisJS RC file contents with default values.
* The RC file contains configuration for providers, preloads, commands, and other
* application settings. This command formats and displays the contents in a readable JSON format.
*
* @example
* ```
* ace inspect:rcfile
* ```
*/
export default class InspectRCFile extends BaseCommand {
/**
* The command name
*/
static commandName = 'inspect:rcfile'
/**
* The command description
*/
static description =
'Display the resolved adonisrc.ts configuration as JSON, including providers, preloads, commands, and meta files'
/**
* Execute the command to display RC file contents.
* Transforms provider, preload, and command entries to display their file paths
* as strings and formats the output as readable JSON.
*/
async run() {
const { raw, providers, preloads, commands, ...rest } = this.app.rcFile
this.logger.log(
JSON.stringify(
{
...rest,
providers: providers.map((provider) => {
return {
...provider,
file: provider.file.toString(),
}
}),
preloads: preloads.map((preload) => {
return {
...preload,
file: preload.file.toString(),
}
}),
commands: commands.map((command) => {
return command.toString()
}),
},
null,
2
)
)
}
}
================================================
FILE: commands/list/routes.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type { CommandOptions } from '../../types/ace.ts'
import { args, BaseCommand, flags } from '../../modules/ace/main.ts'
import { RoutesListFormatter } from '../../src/cli_formatters/routes_list.ts'
/**
* Command to display a list of all registered routes in the application.
* Supports filtering by keywords, middleware, and output formatting options.
* Routes can be displayed as a formatted list, table, or JSON.
*
* @example
* ```
* ace list:routes
* ace list:routes user
* ace list:routes --middleware=auth
* ace list:routes --ignore-middleware=guest
* ace list:routes --json
* ace list:routes --table
* ```
*/
export default class ListRoutes extends BaseCommand {
/**
* The command name
*/
static commandName = 'list:routes'
/**
* The command description
*/
static description =
'List all registered routes with their HTTP methods, URL patterns, handlers, and middleware'
/**
* Command options configuration.
* Requires the application to be started so routes are loaded.
*/
static options: CommandOptions = {
startApp: true,
}
/**
* Keyword to match against route names, patterns, and controller names
*/
@args.string({
description:
'Find routes matching the given keyword. Route name, pattern and controller name will be searched against the keyword',
required: false,
})
declare match: string
/**
* Filter routes that include all specified middleware names
*/
@flags.array({
description:
'View routes that includes all the mentioned middleware names. Use * to see routes that are using one or more middleware',
})
declare middleware: string[]
/**
* Filter routes that do not include all specified middleware names
*/
@flags.array({
description:
'View routes that does not include all the mentioned middleware names. Use * to see routes that are using zero middleware',
})
declare ignoreMiddleware: string[]
/**
* Output routes as JSON format
*/
@flags.boolean({ description: 'Get routes list as a JSON string' })
declare json: boolean
/**
* Output routes as a CLI table format
*/
@flags.boolean({ description: 'View list of routes as a table' })
declare table: boolean
/**
* Output routes as JSONL (one JSON object per line), optimized for
* machine consumption by AI agents and CLI tools
*/
@flags.boolean({
description: 'Get routes as JSONL, one JSON object per line (optimized for AI agents)',
})
declare jsonl: boolean
/**
* Execute the command to list application routes.
* Creates a formatter with the specified filters and outputs routes
* in the requested format (JSON, table, or formatted list).
*/
async run() {
const router = await this.app.container.make('router')
const formatter = new RoutesListFormatter(
router,
this.ui,
{},
{
ignoreMiddleware: this.ignoreMiddleware,
middleware: this.middleware,
match: this.match,
}
)
/**
* Display as JSONL (one JSON object per line).
* Auto-selected when running inside an AI agent and no
* explicit format flag is provided.
*/
if (this.jsonl || (!this.json && !this.table && this.app.runningInAIAgent)) {
const lines = await formatter.formatAsJSONL()
for (const line of lines) {
this.logger.log(line)
}
return
}
/**
* Display as JSON
*/
if (this.json) {
this.logger.log(JSON.stringify(await formatter.formatAsJSON(), null, 2))
return
}
/**
* Display as a standard table
*/
if (this.table) {
const tables = await formatter.formatAsAnsiTable()
tables.forEach((table) => {
this.logger.log('')
if (table.heading) {
this.logger.log(table.heading)
this.logger.log('')
}
table.table.render()
})
return
}
/**
* Display as a list
*/
const list = await formatter.formatAsAnsiList()
list.forEach((item) => {
this.logger.log('')
if (item.heading) {
this.logger.log(item.heading)
this.logger.log('')
}
this.logger.log(item.rows.join('\n'))
})
}
}
================================================
FILE: commands/make/command.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags } from '../../modules/ace/main.ts'
import { BaseCommand } from '../../modules/ace/main.ts'
/**
* Command to create a new Ace command class.
* Ace commands are CLI commands that can be executed via the `ace` binary,
* allowing you to create custom functionality for your application's command line interface.
*
* @example
* ```
* ace make:command SendEmails
* ace make:command ProcessPayments
* ace make:command GenerateReports
* ace make:command CleanupFiles
* ```
*/
export default class MakeCommand extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:command'
/**
* The command description
*/
static description = 'Create a new Ace CLI command class in commands/'
/**
* Name of the command class to create
*/
@args.string({ description: 'Name of the command' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the command class
*/
protected stubPath: string = 'make/command/main.stub'
/**
* Execute the command to create a new Ace command class.
* Generates the command file with proper CLI command structure.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/controller.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import string from '@poppinss/utils/string'
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* The make controller command to create an HTTP controller
*
* @example
* ```
* ace make:controller User
* ace make:controller User store update
* ace make:controller User --resource
* ace make:controller User --api
* ace make:controller User --singular
* ```
*/
export default class MakeController extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:controller'
/**
* The command description
*/
static description =
'Create a new HTTP controller class in app/controllers. Use --resource for CRUD methods or --api for API-only CRUD (no create/edit)'
/**
* Command options configuration
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* The name of the controller
*/
@args.string({ description: 'The name of the controller' })
declare name: string
/**
* Create controller with custom method names
*/
@args.spread({ description: 'Create controller with custom method names', required: false })
declare actions?: string[]
/**
* Generate controller in singular form
*/
@flags.boolean({
description: 'Generate controller in singular form',
alias: 's',
})
declare singular: boolean
/**
* Generate resourceful controller with methods to perform CRUD actions on a resource
*/
@flags.boolean({
description:
'Generate resourceful controller with methods to perform CRUD actions on a resource',
alias: 'r',
})
declare resource: boolean
/**
* Generate resourceful controller without the "edit" and the "create" methods
*/
@flags.boolean({
description: 'Generate resourceful controller without the "edit" and the "create" methods',
alias: 'a',
})
declare api: boolean
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub to use for generating the controller
*/
protected stubPath: string = 'make/controller/main.stub'
/**
* Preparing the command state
*/
async prepare() {
/**
* Use actions stub
*/
if (this.actions) {
this.stubPath = 'make/controller/actions.stub'
}
/**
* Use resource stub
*/
if (this.resource) {
if (this.actions) {
this.logger.warning('Cannot use --resource flag with actions. Ignoring --resource')
} else {
this.stubPath = 'make/controller/resource.stub'
}
}
/**
* Use api stub
*/
if (this.api) {
if (this.actions) {
this.logger.warning('Cannot use --api flag with actions. Ignoring --api')
} else {
this.stubPath = 'make/controller/api.stub'
}
}
/**
* Log warning when both flags are used together
*/
if (this.resource && this.api && !this.actions) {
this.logger.warning('--api and --resource flags cannot be used together. Ignoring --resource')
}
}
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
actions: this.actions?.map((action) => string.camelCase(action)),
entity: this.app.generators.createEntity(this.name),
singular: this.singular,
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/event.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Command to create a new event class.
* Events are data objects that encapsulate information about something
* that happened in your application and can be dispatched to listeners.
*
* @example
* ```
* ace make:event UserRegistered
* ace make:event OrderCompleted
* ace make:event EmailSent
* ```
*/
export default class MakeEvent extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:event'
/**
* The command description
*/
static description =
'Create a new event class in app/events. Events are dispatched via emitter and handled by listeners'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the event class to create
*/
@args.string({ description: 'Name of the event' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the event class
*/
protected stubPath: string = 'make/event/main.stub'
/**
* Execute the command to create a new event class.
* Generates the event file with proper event structure.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/exception.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Command to create a new custom exception class.
* Custom exceptions allow you to define specific error types for your application
* with custom error messages, status codes, and error handling logic.
*
* @example
* ```
* ace make:exception ValidationException
* ace make:exception UnauthorizedException
* ace make:exception ResourceNotFoundException
* ```
*/
export default class MakeException extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:exception'
/**
* The command description
*/
static description =
'Create a new custom exception class in app/exceptions with handle and report methods'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the exception class to create
*/
@args.string({ description: 'Name of the exception' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the exception class
*/
protected stubPath: string = 'make/exception/main.stub'
/**
* Execute the command to create a new custom exception class.
* Generates the exception file with proper error handling structure.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/listener.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Command to create a new event listener class.
* Event listeners handle events dispatched by the application and can optionally
* generate the corresponding event class automatically.
*
* @example
* ```
* ace make:listener UserRegistered
* ace make:listener EmailSent --event=EmailSent
* ace make:listener OrderCompleted --event=OrderEvent
* ```
*/
export default class MakeListener extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:listener'
/**
* The command description
*/
static description =
'Create a new event listener class in app/listeners. Use --event to also generate the event class and bind them together'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the event listener class to create
*/
@args.string({ description: 'Name of the event listener' })
declare name: string
/**
* Generate an event class alongside the listener and bind them together
*/
@flags.string({
description: 'Generate an event class alongside the listener',
alias: 'e',
})
declare event: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the event listener
*/
protected stubPath: string = 'make/listener/main.stub'
/**
* Prepare the command by selecting the appropriate stub based on options.
* Uses a different stub when generating a listener for a specific event.
*/
prepare() {
if (this.event) {
this.stubPath = 'make/listener/for_event.stub'
}
}
/**
* Execute the command to create a new event listener.
* If an event is specified, creates the event class first,
* then generates the listener with proper event binding.
*/
async run() {
const codemods = await this.createCodemods()
if (this.event) {
const { exitCode } = await this.kernel.exec('make:event', [this.event])
/**
* Create listener only when make:event is completed successfully
*/
if (exitCode === 0) {
const eventEntity = this.app.generators.createEntity(this.event)
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
event: eventEntity,
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
return
}
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/middleware.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import string from '@poppinss/utils/string'
import { basename, extname, relative } from 'node:path'
import { stubsRoot } from '../../stubs/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
import stringHelpers from '../../src/helpers/string.ts'
import { args, BaseCommand, flags } from '../../modules/ace/main.ts'
/**
* The make middleware command to create a new middleware
* class.
*
* @example
* ```
* ace make:middleware Auth
* ace make:middleware Auth --stack=server
* ace make:middleware Auth --stack=named
* ace make:middleware Auth --stack=router
* ```
*/
export default class MakeMiddleware extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:middleware'
/**
* The command description
*/
static description =
'Create a new middleware class in app/middleware and register it in start/kernel.ts under the chosen stack (server, router, or named)'
/**
* Command options configuration
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the middleware
*/
@args.string({ description: 'Name of the middleware' })
declare name: string
/**
* The stack in which to register the middleware
*/
@flags.string({ description: 'The stack in which to register the middleware', alias: 's' })
declare stack?: 'server' | 'named' | 'router'
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub to use for generating the middleware
*/
protected stubPath: string = 'make/middleware/main.stub'
async run() {
const stackChoices = ['server', 'router', 'named']
/**
* Prompt to select the stack under which to register
* the middleware
*/
if (!this.stack) {
this.stack = await this.prompt.choice(
'Under which stack you want to register the middleware?',
stackChoices
)
}
/**
* Error out when mentioned stack is invalid
*/
if (!stackChoices.includes(this.stack)) {
this.exitCode = 1
this.logger.error(
`Invalid middleware stack "${this.stack}". Select from "${stackChoices.join(', ')}"`
)
return
}
/**
* Create middleware
*/
const codemods = await this.createCodemods()
const { destination } = await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
/**
* Creative relative path for the middleware file from
* the "./app/middleware" directory
*/
const middlewareRelativePath = stringHelpers.toUnixSlash(
relative(this.app.middlewarePath(), destination).replace(extname(destination), '')
)
/**
* Take the middleware relative path, remove `_middleware` prefix from it
* and convert everything to camelcase
*/
const name = string.camelCase(basename(middlewareRelativePath).replace(/_middleware$/, ''))
/**
* Register middleware
*/
await codemods.registerMiddleware(this.stack, [
{
name: name,
path: `#middleware/${middlewareRelativePath}`,
},
])
}
}
================================================
FILE: commands/make/preload.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { extname, relative } from 'node:path'
import type { AppEnvironments } from '@adonisjs/application/types'
import { stubsRoot } from '../../stubs/main.ts'
import stringHelpers from '../../src/helpers/string.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'] satisfies AppEnvironments[]
type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS
/**
* Command to create a new preload file in the start directory.
* Preload files are executed during application startup and can be used
* to set up global configurations, register global bindings, or perform
* application-wide initialization tasks.
*
* @example
* ```
* ace make:preload routes
* ace make:preload database --register
* ace make:preload events --no-register
* ace make:preload kernel --environments=web,console
* ```
*/
export default class MakePreload extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:preload'
/**
* The command description
*/
static description =
'Create a new preload file in start/ and optionally register it in adonisrc.ts. Preload files run during app boot'
/**
* Name of the preload file to create
*/
@args.string({ description: 'Name of the preload file' })
declare name: string
/**
* Automatically register the preload file in the .adonisrc.ts file
*/
@flags.boolean({
description: 'Auto register the preload file inside the .adonisrc.ts file',
showNegatedVariantInHelp: true,
alias: 'r',
})
declare register?: boolean
/**
* Application environments where the preload file should be loaded
*/
@flags.array({
description: `Define the preload file's environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
alias: 'e',
})
declare environments?: AllowedAppEnvironments
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the preload file
*/
protected stubPath: string = 'make/preload/main.stub'
/**
* Validate that all specified environments are valid application environments.
*
* @returns True if all environments are valid or none specified, false otherwise
*/
#isEnvironmentsFlagValid() {
if (!this.environments || !this.environments.length) {
return true
}
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one))
}
/**
* Execute the command to create a new preload file.
* Validates inputs, generates the preload file, and optionally registers it in .adonisrc.ts.
*/
async run() {
/**
* Ensure the environments are valid when provided via flag
*/
if (!this.#isEnvironmentsFlagValid()) {
this.logger.error(
`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`
)
return
}
/**
* Display prompt to know if we should register the preload
* file inside the ".adonisrc.ts" file.
*/
if (this.register === undefined) {
this.register = await this.prompt.confirm(
'Do you want to register the preload file in .adonisrc.ts file?'
)
}
const codemods = await this.createCodemods()
const { destination } = await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
/**
* Do not register when prompt has been denied or "--no-register"
* flag was used
*/
if (!this.register) {
return
}
/**
* Creative relative path for the preload file from
* the "./start" directory
*/
const preloadFileRelativePath = stringHelpers.toUnixSlash(
relative(this.app.startPath(), destination).replace(extname(destination), '')
)
await codemods.updateRcFile((rcFile) => {
rcFile.addPreloadFile(`#start/${preloadFileRelativePath}`, this.environments)
})
}
}
================================================
FILE: commands/make/provider.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { extname, relative } from 'node:path'
import { stubsRoot } from '../../stubs/main.ts'
import type { AppEnvironments } from '../../types/app.ts'
import stringHelpers from '../../src/helpers/string.ts'
import { args, BaseCommand, flags } from '../../modules/ace/main.ts'
const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'] satisfies AppEnvironments[]
type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS
/**
* Command to create a new service provider class.
* Service providers are used to register bindings, configure services,
* and bootstrap application components during startup.
*
* @example
* ```
* ace make:provider AuthProvider
* ace make:provider DatabaseProvider --register
* ace make:provider AppProvider --no-register
* ace make:provider CacheProvider --environments=web,console
* ```
*/
export default class MakeProvider extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:provider'
/**
* The command description
*/
static description =
'Create a new service provider in providers/ and optionally register it in adonisrc.ts. Providers register IoC container bindings'
/**
* Name of the service provider to create
*/
@args.string({ description: 'Name of the provider' })
declare name: string
/**
* Automatically register the provider in the .adonisrc.ts file
*/
@flags.boolean({
description: 'Auto register the provider inside the .adonisrc.ts file',
showNegatedVariantInHelp: true,
alias: 'r',
})
declare register?: boolean
/**
* Application environments where the provider should be loaded
*/
@flags.array({
description: `Define the provider environment. Accepted values are "${ALLOWED_ENVIRONMENTS}"`,
alias: 'e',
})
declare environments?: AllowedAppEnvironments
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the provider class
*/
protected stubPath: string = 'make/provider/main.stub'
/**
* Validate that all specified environments are valid application environments.
*
* @returns True if all environments are valid or none specified, false otherwise
*/
#isEnvironmentsFlagValid() {
if (!this.environments || !this.environments.length) {
return true
}
return this.environments.every((one) => ALLOWED_ENVIRONMENTS.includes(one))
}
/**
* Execute the command to create a new service provider.
* Validates inputs, generates the provider file, and optionally registers it in .adonisrc.ts.
*/
async run() {
/**
* Ensure the environments are valid when provided via flag
*/
if (!this.#isEnvironmentsFlagValid()) {
this.logger.error(
`Invalid environment(s) "${this.environments}". Only "${ALLOWED_ENVIRONMENTS}" are allowed`
)
return
}
/**
* Display prompt to know if we should register the provider
* file inside the ".adonisrc.ts" file.
*/
if (this.register === undefined) {
this.register = await this.prompt.confirm(
'Do you want to register the provider in .adonisrc.ts file?'
)
}
const codemods = await this.createCodemods()
const { destination } = await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
/**
* Do not register when prompt has been denied or "--no-register"
* flag was used
*/
if (!this.register) {
return
}
/**
* Creative relative path for the provider file from
* the "./start" directory
*/
const providerRelativePath = stringHelpers.toUnixSlash(
relative(this.app.providersPath(), destination).replace(extname(destination), '')
)
await codemods.updateRcFile((rcFile) => {
rcFile.addProvider(`#providers/${providerRelativePath}`, this.environments)
})
}
}
================================================
FILE: commands/make/service.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Make a new service class
*
* @example
* ```
* ace make:service UserService
* ace make:service AuthService
* ace make:service User/ProfileService
* ```
*/
export default class MakeService extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:service'
/**
* The command description
*/
static description =
'Create a new service class in app/services. Services encapsulate reusable business logic outside of controllers'
/**
* Command options configuration
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the service
*/
@args.string({ description: 'Name of the service' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub to use for generating the service class
*/
protected stubPath: string = 'make/service/main.stub'
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/test.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
/**
* Command to create a new Japa test file.
* Supports multiple test suites and automatically detects or prompts for
* the appropriate suite and directory based on application configuration.
*
* @example
* ```
* ace make:test UserController
* ace make:test UserModel --suite=unit
* ace make:test AuthService --suite=integration
* ```
*/
export default class MakeTest extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:test'
/**
* The command description
*/
static description =
'Create a new Japa test file in tests/. Use --suite to specify the test suite (unit, functional, etc.)'
/**
* Name of the test file to create
*/
@args.string({ description: 'Name of the test file' })
declare name: string
/**
* Test suite name where the test file should be created
*/
@flags.string({ description: 'The suite for which to create the test file', alias: 's' })
declare suite?: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the test file
*/
protected stubPath: string = 'make/test/main.stub'
/**
* Determine the test suite name for creating the test file.
* Uses the provided suite flag, or automatically selects if only one suite exists,
* or prompts the user to choose from available suites.
*
* @returns The name of the selected test suite
*/
async #getSuite(): Promise<string> {
if (this.suite) {
return this.suite
}
/**
* Use the first suite from the rcFile when there is only
* one suite
*/
const rcFileSuites = this.app.rcFile.tests.suites
if (rcFileSuites.length === 1) {
return rcFileSuites[0].name
}
/**
* Prompt the user to select a suite manually
*/
return this.prompt.choice(
'Select the suite for the test file',
this.app.rcFile.tests.suites.map((suite) => {
return suite.name
}),
{
validate(choice) {
return choice ? true : 'Please select a suite'
},
}
)
}
/**
* Determine the directory path for the test file within the selected suite.
* Automatically selects if only one directory exists, otherwise prompts the user.
*
* @param directories - Array of available directories for the suite
* @returns The selected directory path
*/
async #getSuiteDirectory(directories: string[]): Promise<string> {
if (directories.length === 1) {
return directories[0]
}
return this.prompt.choice('Select directory for the test file', directories, {
validate(choice) {
return choice ? true : 'Please select a directory'
},
})
}
/**
* Find suite configuration from the RC file by name.
*
* @param suiteName - The name of the suite to find
* @returns The suite configuration or undefined if not found
*/
#findSuite(suiteName: string) {
return this.app.rcFile.tests.suites.find((suite) => {
return suite.name === suiteName
})
}
/**
* Execute the command to create a new test file.
* Validates the suite exists, prompts for missing information,
* and generates the test file in the appropriate location.
*/
async run() {
const suite = this.#findSuite(await this.#getSuite())
/**
* Show error when mentioned/selected suite does not exist
*/
if (!suite) {
this.logger.error(`The "${this.suite}" suite is not configured inside the "adonisrc.js" file`)
this.exitCode = 1
return
}
/**
* Generate entity
*/
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
suite: {
directory: await this.#getSuiteDirectory(suite.directories),
},
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/transformer.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Command to create a new transformer class.
* Transformers are used to serialize data objects (like models) into specific
* formats for API responses, allowing you to control which fields are exposed
* and how data is structured for clients.
*
* @example
* ```
* ace make:transformer User
* ace make:transformer Post
* ace make:transformer ProductTransformer
* ```
*/
export default class MakeTransformer extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:transformer'
/**
* The command description
*/
static description =
'Create a new transformer class in app/transformers for serializing data in API responses'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the entity for which to generate the transformer
*/
@args.string({ description: 'Entity name for which to generate the transformer' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the transformer class
*/
protected stubPath: string = 'make/transformer/main.stub'
/**
* Execute the command to create a new transformer class.
* Generates the transformer file with proper data serialization structure.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
model: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/validator.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
import { type CommandOptions } from '../../types/ace.ts'
/**
* Command to create a new VineJS validator file.
* Validators define reusable validation schemas for request validation,
* and can be generated as simple validators or resource-based validators
* with create and update schemas.
*
* @example
* ```
* ace make:validator UserValidator
* ace make:validator PostValidator --resource
* ace make:validator ContactValidator
* ```
*/
export default class MakeValidator extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:validator'
/**
* The command description
*/
static description =
'Create a new VineJS validator file in app/validators. Use --resource to generate both create and update validation schemas'
/**
* Command options configuration.
* Allows unknown flags to be passed through.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
}
/**
* Name of the validator file to create
*/
@args.string({ description: 'Name of the validator file' })
declare name: string
/**
* Generate a resource validator with create and update schemas
*/
@flags.boolean({
description: 'Create a file with pre-defined validators for create and update actions',
})
declare resource: boolean
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the validator
*/
protected stubPath: string = 'make/validator/main.stub'
/**
* Prepare the command by selecting the appropriate stub based on options.
* Uses a resource stub when generating validators for CRUD operations.
*/
async prepare() {
/**
* Use resource stub
*/
if (this.resource) {
this.stubPath = 'make/validator/resource.stub'
}
}
/**
* Execute the command to create a new VineJS validator file.
* Generates the validator with the appropriate stub template.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/make/view.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { stubsRoot } from '../../stubs/main.ts'
import { args, flags, BaseCommand } from '../../modules/ace/main.ts'
/**
* Command to create a new Edge.js template file.
* Edge templates are used for rendering HTML views in your web application,
* supporting layouts, partials, components, and template inheritance.
*
* @example
* ```
* ace make:view home
* ace make:view users/profile
* ace make:view components/navbar
* ace make:view layouts/app
* ```
*/
export default class MakeView extends BaseCommand {
/**
* The command name
*/
static commandName = 'make:view'
/**
* The command description
*/
static description = 'Create a new Edge.js template file in resources/views'
/**
* Name of the template file to create
*/
@args.string({ description: 'Name of the template' })
declare name: string
/**
* Read the contents from this file (if the flag exists) and use
* it as the raw contents
*/
@flags.string({ description: 'Use the contents of the given file as the generated output' })
declare contentsFrom: string
/**
* The stub template file to use for generating the Edge template
*/
protected stubPath: string = 'make/view/main.stub'
/**
* Execute the command to create a new Edge.js template file.
* Generates the template file in the views directory.
*/
async run() {
const codemods = await this.createCodemods()
await codemods.makeUsingStub(
stubsRoot,
this.stubPath,
{
flags: this.parsed.flags,
entity: this.app.generators.createEntity(this.name),
},
{
contentsFromFile: this.contentsFrom,
}
)
}
}
================================================
FILE: commands/repl.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BaseCommand } from '../modules/ace/main.ts'
import { type CommandOptions } from '../types/ace.ts'
/**
* Command to start an interactive REPL (Read-Eval-Print Loop) session for AdonisJS.
* The REPL provides a command-line interface where you can execute JavaScript code
* in the context of your AdonisJS application, allowing you to interact with models,
* services, and other application components in real-time.
*
* @example
* ```
* ace repl
* ```
*/
export default class ReplCommand extends BaseCommand {
/**
* The command name
*/
static commandName = 'repl'
/**
* The command description
*/
static description =
'Start an interactive REPL session with the application booted and IoC container available'
/**
* Command options configuration.
* Requires the application to be started and keeps the process alive.
*/
static options: CommandOptions = {
startApp: true,
staysAlive: true,
}
/**
* Execute the command to start the REPL server.
* Creates a REPL instance from the container and sets up an exit handler
* that properly terminates the application when the REPL session ends.
*/
async run() {
const repl = await this.app.container.make('repl')
repl.start()
repl.server!.on('exit', async () => {
await this.terminate()
})
}
}
================================================
FILE: commands/serve.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type { DevServer } from '@adonisjs/assembler'
import { importAssembler } from '../src/utils.ts'
import type { CommandOptions } from '../types/ace.ts'
import { BaseCommand, flags } from '../modules/ace/main.ts'
/**
* Serve command is used to run the AdonisJS HTTP server during development. The
* command under the hood runs the "bin/server.ts" file and watches for file
* system changes
*
* @example
* ```
* ace serve
* ace serve --watch
* ace serve --hmr
* ace serve --poll
* ace serve --no-clear
* ```
*/
export default class Serve extends BaseCommand {
/**
* The command name
*/
static commandName = 'serve'
/**
* The command description
*/
static description =
'Start the development HTTP server. Use --watch for auto-restart on file change or --hmr for hot module replacement'
/**
* Help text for the command
*/
static help = [
'Start the development server with file watcher using the following command.',
'```',
'{{ binaryName }} serve --watch',
'```',
'',
'You can also start the server with HMR support using the following command.',
'```',
'{{ binaryName }} serve --hmr',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
'You may pass vite CLI args using the --assets-args command line flag.',
'```',
'{{ binaryName }} serve --assets-args="--debug --base=/public"',
'```',
]
/**
* Command options configuration
*/
static options: CommandOptions = {
staysAlive: true,
}
/**
* The development server instance
*/
declare devServer: DevServer
/**
* Start the server with HMR support
*/
@flags.boolean({ description: 'Start the server with HMR support' })
declare hmr?: boolean
/**
* Watch filesystem and restart the HTTP server on file change
*/
@flags.boolean({
description: 'Watch filesystem and restart the HTTP server on file change',
alias: 'w',
})
declare watch?: boolean
/**
* Use polling to detect filesystem changes
*/
@flags.boolean({ description: 'Use polling to detect filesystem changes', alias: 'p' })
declare poll?: boolean
/**
* Clear the terminal for new logs after file change
*/
@flags.boolean({
description: 'Clear the terminal for new logs after file change',
showNegatedVariantInHelp: true,
default: true,
})
declare clear?: boolean
/**
* Log a development dependency is missing
*
* @param dependency - The name of the missing dependency
*/
#logMissingDevelopmentDependency(dependency: string) {
this.logger.error(
[
`Cannot find package "${dependency}"`,
'',
`The "${dependency}" package is a development dependency and therefore you should use the serve command during development only.`,
'',
'If you are running your application in production, then use "node bin/server.js" command to start the HTTP server',
].join('\n')
)
}
/**
* Runs the HTTP server
*/
async run() {
const assembler = await importAssembler(this.app)
if (!assembler) {
this.#logMissingDevelopmentDependency('@adonisjs/assembler')
this.exitCode = 1
return
}
if (this.watch && this.hmr) {
this.logger.error('Cannot use --watch and --hmr flags together. Choose one of them')
this.exitCode = 1
return
}
this.devServer = new assembler.DevServer(this.app.appRoot, {
hmr: this.hmr === true ? true : false,
clearScreen: this.clear === false ? false : true,
nodeArgs: this.parsed.nodeArgs,
scriptArgs: [],
metaFiles: this.app.rcFile.metaFiles,
hooks: this.app.rcFile.hooks,
})
/**
* Share command logger with assembler, so that CLI flags like --no-ansi has
* similar impact for assembler logs as well.
*/
this.devServer.ui.logger = this.logger
/**
* Exit command when the dev server is closed
*/
this.devServer.onClose((exitCode) => {
this.exitCode = exitCode
this.terminate()
})
/**
* Exit command when the dev server crashes
*/
this.devServer.onError(() => {
this.exitCode = 1
this.terminate()
})
/**
* Start the development server
*/
if (this.watch) {
await this.devServer.startAndWatch({ poll: this.poll || false })
} else {
await this.devServer.start()
}
}
}
================================================
FILE: commands/test.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import type { TestRunner } from '@adonisjs/assembler'
import { importAssembler } from '../src/utils.ts'
import type { CommandOptions } from '../types/ace.ts'
import { BaseCommand, flags, args } from '../modules/ace/main.ts'
/**
* Command to run application tests using the Japa test runner.
* Supports filtering tests by suites, files, tags, groups, and individual tests.
* Can run in watch mode to automatically re-run tests when files change.
*
* @example
* ```
* ace test
* ace test unit integration
* ace test --watch
* ace test --files=user.spec.ts
* ace test --tags=slow --groups="User tests"
* ace test --reporters=spec,dot
* ace test --timeout=5000 --retries=2
* ```
*/
export default class Test extends BaseCommand {
/**
* The command name
*/
static commandName = 'test'
/**
* The command description
*/
static description =
'Run tests using Japa test runner. Supports filtering by suite, file, tag, and group. Use --watch for re-runs on file change'
/**
* Command options configuration.
* Allows unknown flags to be passed to Japa and keeps the process alive.
*/
static options: CommandOptions = {
allowUnknownFlags: true,
staysAlive: true,
}
/**
* The test runner instance from the assembler package
*/
declare testsRunner: TestRunner
/**
* Test suite names to run. When provided, only tests from the specified suites will be executed
*/
@args.spread({
description: 'Mention suite names to run tests for selected suites',
required: false,
})
declare suites?: string[]
/**
* Filter tests by filename patterns
*/
@flags.array({ description: 'Filter tests by the filename' })
declare files?: string[]
/**
* Filter tests by tags
*/
@flags.array({ description: 'Filter tests by tags' })
declare tags?: string[]
/**
* Filter tests by parent group title
*/
@flags.array({ description: 'Filter tests by parent group title' })
declare groups?: string[]
/**
* Filter tests by test title
*/
@flags.array({ description: 'Filter tests by test title' })
declare tests?: string[]
/**
* Specify one or more test reporters to use for output formatting
*/
@flags.array({ description: 'Activate one or more test reporters' })
declare reporters?: string[]
/**
* Enable watch mode to automatically re-run tests when files change
*/
@flags.boolean({ description: 'Watch filesystem and re-run tests on file change' })
declare watch?: boolean
/**
* Use polling instead of native filesystem events to detect file changes
*/
@flags.boolean({ description: 'Use polling to detect filesystem changes' })
declare poll?: boolean
/**
* Default timeout in milliseconds for all tests
*/
@flags.number({ description: 'Define default timeout for all tests' })
declare timeout?: number
/**
* Default number of retries for failed tests
*/
@flags.number({ description: 'Define default retries for all tests' })
declare retries?: number
/**
* Execute only tests that failed during the last run
*/
@flags.boolean({ description: 'Execute tests failed during the last run' })
declare failed?: boolean
/**
* Clear the terminal for new logs after file change in watch mode
*/
@flags.boolean({
description: 'Clear the terminal for new logs after file change',
showNegatedVariantInHelp: true,
default: true,
})
declare clear?: boolean
/**
* Log an error message when a required development dependency is missing.
* Provides helpful instructions for resolving the issue.
*
* @param dependency - The name of the missing dependency package
*/
#logMissingDevelopmentDependency(dependency: string) {
this.logger.error(
[
`Cannot find package "${dependency}"`,
'',
`The "${dependency}" package is a development dependency and therefore you should run tests with development dependencies installed.`,
'',
'If you are run tests inside a CI, make sure the NODE_ENV is set to "development"',
].join('\n')
)
}
/**
* Collect unknown flags and format them to pass to the Japa test runner.
* Handles boolean flags, arrays, and single values appropriately.
*
* @returns Array of formatted command-line arguments for Japa
*/
#getPassthroughFlags(): string[] {
return this.parsed.unknownFlags
.map((flag) => {
const value = this.parsed.flags[flag]
/**
* Not mentioning value when value is "true"
*/
if (value === true) {
return [`--${flag}`] as string[]
}
/**
* Repeating flag multiple times when value is an array
*/
if (Array.isArray(value)) {
return value.map((v) => [`--${flag}`, v]) as string[][]
}
return [`--${flag}`, value] as string[]
})
.flat(2)
}
/**
* Execute the test command. Sets up the test runner with all configured options
* and filters, then runs tests either once or in watch mode. Handles missing
* dependencies and properly configures the test environment.
*/
async run() {
process.env.NODE_ENV = 'test'
const assembler = await importAssembler(this.app)
if (!assembler) {
this.#logMissingDevelopmentDependency('@adonisjs/assembler')
this.exitCode = 1
return
}
this.testsRunner = new assembler.TestRunner(this.app.appRoot, {
clearScreen: this.clear === false ? false : true,
nodeArgs: this.parsed.nodeArgs,
scriptArgs: this.#getPassthroughFlags(),
filters: {
suites: this.suites,
files: this.files,
groups: this.groups,
tags: this.tags,
tests: this.tests,
},
failed: this.failed,
retries: this.retries,
timeout: this.timeout,
reporters: this.reporters,
suites: this.app.rcFile.tests.suites.map((suite) => {
return {
name: suite.name,
files: suite.files,
}
}),
env: {
NODE_ENV: 'test',
},
hooks: this.app.rcFile.hooks,
metaFiles: this.app.rcFile.metaFiles,
})
/**
* Share command logger with assembler, so that CLI flags like --no-ansi has
* similar impact for assembler logs as well.
*/
this.testsRunner.ui.logger = this.logger
/**
* Exit command when the test runner is closed
*/
this.testsRunner.onClose((exitCode) => {
this.exitCode = exitCode
this.terminate()
})
/**
* Exit command when the dev server crashes
*/
this.testsRunner.onError(() => {
this.exitCode = 1
this.terminate()
})
/**
* Start the test runner in watch mode
*/
if (this.watch) {
await this.testsRunner.runAndWatch({ poll: this.poll || false })
} else {
await this.testsRunner.run()
}
}
}
================================================
FILE: eslint.config.js
================================================
import { configPkg } from '@adonisjs/eslint-config'
export default configPkg({
ignores: ['coverage'],
})
================================================
FILE: factories/app.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/application/factories'
================================================
FILE: factories/bodyparser.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/bodyparser/factories'
================================================
FILE: factories/core/ace.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { IgnitorFactory } from './ignitor.ts'
import { Ignitor } from '../../src/ignitor/main.ts'
import type { IgnitorOptions } from '../../src/types.ts'
import type { Kernel } from '../../modules/ace/kernel.ts'
import { createAceKernel } from '../../modules/ace/create_kernel.ts'
/**
* Factory for creating and configuring Ace command kernel instances.
* This factory provides a convenient way to create Ace kernels either from
* an existing Ignitor instance or by creating a new one from scratch.
*
* @example
* ```ts
* // Create from URL
* const aceFactory = new AceFactory()
* const kernel = await aceFactory.make(new URL('../', import.meta.url))
*
* // Create from existing ignitor
* const ignitor = new Ignitor(appRoot)
* const kernel = await aceFactory.make(ignitor)
*
* // Run commands
* await kernel.handle(['make:controller', 'UserController'])
* ```
*/
export class AceFactory {
/**
* Create an Ace kernel from an existing Ignitor instance
*
* @param ignitor - Existing Ignitor instance
*/
async make(ignitor: Ignitor): Promise<Kernel>
/**
* Create an Ace kernel from application root URL
*
* @param appRoot - Application root directory URL
* @param options - Optional Ignitor configuration options
*/
async make(appRoot: URL, options?: IgnitorOptions): Promise<Kernel>
async make(ignitorOrAppRoot: URL | Ignitor, options?: IgnitorOptions): Promise<Kernel> {
if (ignitorOrAppRoot instanceof Ignitor) {
const app = ignitorOrAppRoot.createApp('console')
await app.init()
return createAceKernel(app)
}
const app = new IgnitorFactory()
.withCoreConfig()
.withCoreProviders()
.create(ignitorOrAppRoot, options!)
.createApp('console')
await app.init()
return createAceKernel(app)
}
}
================================================
FILE: factories/core/ignitor.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Ignitor } from '../../src/ignitor/main.ts'
import type { ProviderNode } from '../../types/app.ts'
import { drivers as hashDrivers } from '../../modules/hash/define_config.ts'
import type { ApplicationService, IgnitorOptions } from '../../src/types.ts'
import { defineConfig as defineLoggerConfig } from '../../modules/logger.ts'
import { defineConfig as defineHashConfig } from '../../modules/hash/main.ts'
import { defineConfig as defineHttpConfig } from '../../modules/http/main.ts'
import { defineConfig as defineBodyParserConfig } from '../../modules/bodyparser/main.ts'
import {
defineConfig as defineEncryptionConfig,
drivers as encryptionDrivers,
} from '../../modules/encryption/define_config.ts'
type FactoryParameters = {
rcFileContents: Record<string, any>
config: Record<string, any>
}
/**
* Factory for creating and configuring AdonisJS Ignitor instances.
* This factory provides a fluent API to set up applications with core providers,
* configurations, and preload actions for testing and development scenarios.
*
* @example
* ```ts
* const ignitor = new IgnitorFactory()
* .withCoreProviders()
* .withCoreConfig()
* .preload((app) => {
* // Custom initialization logic
* })
* .create(new URL('../', import.meta.url))
*
* const app = ignitor.createApp('web')
* await app.boot()
* ```
*/
export class IgnitorFactory {
#preloadActions: ((app: ApplicationService) => Promise<void> | void)[] = []
#parameters: Partial<FactoryParameters> = {}
/**
* A flag to know if we should load the core providers
*/
#loadCoreProviders: boolean = false
/**
* Define preload actions to run during application initialization.
* These actions are executed after the application is booted.
*
* @param action - Function to execute during preload phase
*
* @example
* ```ts
* factory.preload((app) => {
* // Register custom bindings
* app.container.bind('customService', () => new CustomService())
* })
* ```
*/
preload(action: (app: ApplicationService) => void | Promise<void>): this {
this.#preloadActions.push(action)
return this
}
/**
* Merge core providers with user defined providers
*/
#mergeCoreProviders(providers?: ProviderNode['file'][]): ProviderNode['file'][] {
const coreProviders: ProviderNode['file'][] = [
() => import('@adonisjs/core/providers/app_provider'),
() => import('@adonisjs/core/providers/hash_provider'),
() => import('@adonisjs/core/providers/repl_provider'),
]
return coreProviders.concat(providers || [])
}
/**
* Merge custom factory parameters with existing ones.
* This allows you to customize RC file contents and application configuration.
*
* @param params - Parameters to merge
* @param params.config - Application configuration to merge
* @param params.rcFileContents - RC file contents to merge
*
* @example
* ```ts
* factory.merge({
* config: {
* database: { connection: 'mysql' }
* },
* rcFileContents: {
* commands: ['./commands/CustomCommand']
* }
* })
* ```
*/
merge(params: Partial<FactoryParameters>): this {
if (params.config) {
this.#parameters.config = Object.assign(this.#parameters.config || {}, params.config)
}
if (params.rcFileContents) {
this.#parameters.rcFileContents = Object.assign(
this.#parameters.rcFileContents || {},
params.rcFileContents
)
}
return this
}
/**
* Include core AdonisJS providers when booting the application.
* This adds essential providers like app, hash, and REPL providers.
*
* @example
* ```ts
* const ignitor = new IgnitorFactory()
* .withCoreProviders()
* .create(appRoot)
* ```
*/
withCoreProviders(): this {
this.#loadCoreProviders = true
return this
}
/**
* Merge default configuration for core AdonisJS features.
* This includes configurations for HTTP, hash, logger, and bodyparser.
* A shallow merge is performed with existing config.
*
* @example
* ```ts
* const ignitor = new IgnitorFactory()
* .withCoreConfig()
* .create(appRoot)
* ```
*/
withCoreConfig(): this {
this.merge({
config: {
app: {
appUrl: 'http://localhost:3333',
http: defineHttpConfig({}),
},
validator: {},
encryption: defineEncryptionConfig({
default: 'gcm',
list: {
gcm: encryptionDrivers.aes256gcm({
id: 'gcm',
keys: ['averylongrandomsecretkey'],
}),
},
}),
bodyparser: defineBodyParserConfig({}),
hash: defineHashConfig({
default: 'scrypt',
list: {
scrypt: hashDrivers.scrypt({}),
},
}),
logger: defineLoggerConfig({
default: 'app',
loggers: {
app: {},
},
}),
},
})
return this
}
/**
* Create a configured Ignitor instance with all specified parameters.
*
* @param appRoot - Application root directory URL
* @param options - Optional Ignitor configuration options
*
* @example
* ```ts
* const ignitor = new IgnitorFactory()
* .withCoreConfig()
* .withCoreProviders()
* .create(new URL('../', import.meta.url))
* ```
*/
create(appRoot: URL, options?: IgnitorOptions): Ignitor {
return new Ignitor(appRoot, options).tap((app) => {
app.booted(async () => {
for (let action of this.#preloadActions) {
await action(app)
}
})
if (this.#loadCoreProviders) {
this.#parameters.rcFileContents = this.#parameters.rcFileContents || {}
this.#parameters.rcFileContents.providers = this.#mergeCoreProviders(
this.#parameters.rcFileContents.providers
)
}
this.#parameters.rcFileContents && app.rcContents(this.#parameters.rcFileContents)
this.#parameters.config && app.useConfig(this.#parameters.config)
})
}
}
================================================
FILE: factories/core/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export { AceFactory } from './ace.ts'
export { IgnitorFactory } from './ignitor.ts'
export { TestUtilsFactory } from './test_utils.ts'
================================================
FILE: factories/core/test_utils.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Ignitor } from '../../index.ts'
import { IgnitorFactory } from './ignitor.ts'
import type { IgnitorOptions } from '../../src/types.ts'
import { TestUtils } from '../../src/test_utils/main.ts'
/**
* Factory for creating TestUtils instances used in AdonisJS testing scenarios.
* This factory provides convenient methods to set up test utilities either from
* an existing Ignitor instance or by creating a new configured one.
*
* @example
* ```ts
* // Create from URL for testing
* const factory = new TestUtilsFactory()
* const testUtils = factory.create(new URL('../', import.meta.url))
*
* // Use in tests
* const app = testUtils.app()
* await app.boot()
*
* // Create HTTP client
* const client = testUtils.httpClient()
* const response = await client.get('/users')
* ```
*/
export class TestUtilsFactory {
/**
* Create TestUtils from an existing Ignitor instance
*
* @param ignitor - Existing Ignitor instance configured for testing
*/
create(ignitor: Ignitor): TestUtils
/**
* Create TestUtils from application root URL with optional configuration
*
* @param appRoot - Application root directory URL
* @param options - Optional Ignitor configuration options
*/
create(appRoot: URL, options?: IgnitorOptions): TestUtils
create(ignitorOrAppRoot: URL | Ignitor, options?: IgnitorOptions): TestUtils {
if (ignitorOrAppRoot instanceof Ignitor) {
return new TestUtils(ignitorOrAppRoot.createApp('test'))
}
return new TestUtils(
new IgnitorFactory()
.withCoreConfig()
.withCoreProviders()
.create(ignitorOrAppRoot, options!)
.createApp('console')
)
}
}
================================================
FILE: factories/encryption.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@boringnode/encryption/factories'
================================================
FILE: factories/events.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/events/factories'
================================================
FILE: factories/hash.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/hash/factories'
================================================
FILE: factories/http.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/http-server/factories'
================================================
FILE: factories/logger.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/logger/factories'
================================================
FILE: factories/stubs.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { AppFactory } from '@adonisjs/application/factories'
import { stubsRoot } from '../index.ts'
import type { ApplicationService } from '../src/types.ts'
type FactoryParameters = {
app: ApplicationService
}
/**
* Factory for preparing and processing stub templates from the "@adonisjs/core" package.
* This factory is designed for internal testing and development purposes, utilizing
* the core package's stub root directory.
*
* Note: This class is not published as it's intended for internal testing only.
*
* @example
* ```ts
* const stubsFactory = new StubsFactory()
*
* // Prepare a controller stub
* const preparedStub = await stubsFactory.prepare('controller.stub', {
* filename: 'UserController',
* entity: { name: 'User' },
* resourceful: true
* })
*
* console.log(preparedStub.contents)
* ```
*/
export class StubsFactory {
#parameters: Partial<FactoryParameters> = {}
/**
* Returns an instance of application, either from parameters or creates a default one
*/
#getApp() {
return this.#parameters.app || new AppFactory().create(new URL('./', import.meta.url))
}
/**
* Merge custom factory parameters to override defaults.
* This allows you to provide a custom application instance.
*
* @param params - Parameters to merge
* @param params.app - Custom application service instance
*
* @example
* ```ts
* const customApp = new AppFactory().create(appRoot)
* const stubsFactory = new StubsFactory().merge({ app: customApp })
* ```
*/
merge(params: Partial<FactoryParameters>): this {
this.#parameters = Object.assign(this.#parameters, params)
return this
}
/**
* Prepare a stub template with the provided data and return the processed content.
* This method initializes the application, loads the stub, and processes it with
* the given template variables.
*
* @param stubPath - Path to the stub file relative to the stubs root
* @param data - Template data to populate the stub placeholders
*
* @example
* ```ts
* const stubsFactory = new StubsFactory()
* const preparedStub = await stubsFactory.prepare('controller.stub', {
* filename: 'UserController',
* entity: {
* name: 'User',
* modelName: 'User',
* pluralName: 'users'
* },
* resourceful: true
* })
*
* // Access the processed stub content
* console.log(preparedStub.contents)
* ```
*/
async prepare(stubPath: string, data: Record<string, any>) {
const app = this.#getApp()
await app.init()
const stubs = await app.stubs.create()
const stub = await stubs.build(stubPath, {
source: stubsRoot,
})
return stub.prepare(data)
}
}
================================================
FILE: funding.json
================================================
{
"version": "v1.0.0",
"entity": {
"type": "individual",
"role": "owner",
"name": "Harminder Virk",
"email": "virk@adonisjs.com",
"description": "Hi 👋 I'm Harminder Virk, the creator of a family of open-source tools loved by the Node.js community — including AdonisJS, VineJS, Japa, Edge, Lucid ORM, and Youch.\n\nI pour my heart into building tools that make developers' lives easier — from crafting elegant APIs to sweating the little details that improve your everyday workflow. My goal is to provide you with strong, reliable building blocks, so you can focus on shipping great products instead of fighting with your stack.\n\nBy sponsoring my work, you're helping me keep these projects fast, stable, and well-maintained, while also making room for new ideas that could become your next favorite tool. ❤️\n\nCurrent focus\n\n- AdonisJS v7\n- Improving E2E type-safety in AdonisJS applications\n- Isomorphic VineJS (Validation library)\n- Lucid Rewrite (ORM)\nAdonisJS Plus (Sponsors can access Plus at a discounted rate)",
"webpageUrl": {
"url": "https://adonisjs.com"
}
},
"projects": [
{
"guid": "adonisjs",
"name": "AdonisJS",
"description": "AdonisJS is a fully typed TypeScript framework that includes everything you need to build robust applications. ORM, authentication, caching, rate limiter, file uploads, and support for testing - all in a single cohesive package",
"webpageUrl": {
"url": "https://adonisjs.com"
},
"repositoryUrl": {
"url": "https://github.com/adonisjs/core"
},
"licenses": ["MIT"],
"tags": [
"web-framework",
"batteries-included",
"fullstack",
"typescript",
"nodejs",
"javascript"
]
},
{
"guid": "japa",
"name": "Japa",
"description": "Japa is a testing framework for Node.js that focuses primarily on testing backend applications. Japa does not require using any build tools and is significantly smaller and faster than Jest and Vitest",
"webpageUrl": {
"url": "https://japa.dev"
},
"repositoryUrl": {
"url": "https://github.com/japa/runner"
},
"licenses": ["MIT"],
"tags": ["testing", "nodejs", "typescript", "javascript"]
},
{
"guid": "vinejs",
"name": "VineJS",
"description": "VineJS is a fast and type-safe validation library for Node.js, designed for validating form data and JSON payloads. It offers 50+ built-in rules, 12 schema types, customizable error messages, and first-class support for extending with custom rules or schema types — all while being one of the fastest libraries in the Node.js ecosystem.",
"webpageUrl": {
"url": "https://vinejs.dev"
},
"repositoryUrl": {
"url": "https://github.com/vinejs/vine"
},
"licenses": ["MIT"],
"tags": ["validation", "validator", "javascript", "nodejs", "typescript"]
},
{
"guid": "edgejs",
"name": "EdgeJS",
"description": "Edge is a simple, Modern, and batteries included template engine for Node.js. In the age of frontend frameworks, Edge allows you to embrace the simplicity of server-side templates.",
"webpageUrl": {
"url": "https://edgejs.dev"
},
"repositoryUrl": {
"url": "https://github.com/edge-js/edge"
},
"licenses": ["MIT"],
"tags": ["templating", "template-engine", "nodejs", "javascript"]
},
{
"guid": "youch",
"name": "Youch",
"description": "Youch is an error-parsing library that pretty prints JavaScript errors on a web page or the terminal.",
"webpageUrl": {
"url": "https://github.com/poppinss/youch"
},
"repositoryUrl": {
"url": "https://github.com/poppinss/youch"
},
"licenses": ["MIT"],
"tags": ["error-parser", "error-printer", "pretty-print", "javascript", "typescript"]
}
],
"funding": {
"channels": [
{
"guid": "gh-sponsors",
"type": "payment-provider",
"address": "https://github.com/sponsors/thetutlage",
"description": "Support me through GitHub Sponsors"
},
{
"guid": "my-paypal",
"type": "payment-provider",
"address": "https://paypal.me/adonisjs",
"description": "Support me through Paypal. Supports various payment options"
}
],
"plans": [
{
"guid": "fan",
"status": "active",
"name": "AdonisJS fan",
"description": "You have directly benefited from my work and want to support me continue working on AdonisJS and other related packages.",
"amount": 5,
"currency": "USD",
"frequency": "monthly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "insiders-individual",
"status": "active",
"name": "Insiders program - Individual",
"description": "All sponsors under this tier are automatically invited to the Insiders program, which provides them with exclusive benefits.\n\n- Open-source packages: Gain early access to alpha release packages with complete documentation, allowing you to provide feedback and influence features before public release.\n- Example projects: Get early access to the source code of production-ready example apps built using AdonisJS. Ask questions around the design decisions, or contribute features to it.",
"amount": 19,
"currency": "USD",
"frequency": "monthly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "insiders-team",
"status": "active",
"name": "Insiders program - Teams",
"description": "Access to Insiders benefits for your entire team (upto 10 members). Along with that you will have access to the following benefits\n\n- Prominent logo placement on the AdonisJS website homepage\n- Featured announcement across AdonisJS social and newsletter channels\n- Thank-you highlight on AdonisJS social channels",
"amount": 499,
"currency": "USD",
"frequency": "monthly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "community",
"status": "active",
"name": "Community Sponsor",
"description": "Community Sponsors are companies and teams who use AdonisJS and want to give back to the tools they depend on. Every contribution helps sustain development and community support.\n\nBenefits:\n\n- Prominent logo placement on the AdonisJS website homepage\n- Thank-you highlight on AdonisJS social channels",
"amount": 1000,
"currency": "USD",
"frequency": "yearly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "core",
"status": "active",
"name": "Core Sponsor",
"description": "Core Sponsors ensure AdonisJS continues to grow and remain dependable for production use. Their support directly funds ongoing maintenance and new integrations.\n\nBenefits:\n\n- Prominent logo placement on the AdonisJS website homepage\n- Featured announcement across AdonisJS social and newsletter channels\n- Thank-you highlight on AdonisJS social channels",
"amount": 5000,
"currency": "USD",
"frequency": "yearly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "prime",
"status": "active",
"name": "Prime Sponsor",
"description": "Prime Sponsors help maintain the momentum behind AdonisJS, supporting consistent releases, improvements, and ecosystem maintenance.\n\nBenefits:\n\n- Logo featured on the AdonisJS sponsor page\n- Mention in annual sponsor announcement post\n- Invitations to private feedback sessions and early previews\n- Thank-you highlight on AdonisJS social channels",
"amount": 10000,
"currency": "USD",
"frequency": "yearly",
"channels": ["gh-sponsors", "my-paypal"]
},
{
"guid": "divine",
"status": "active",
"name": "Divine Sponsor",
"description": "Divine Sponsors play a foundational role in keeping the AdonisJS ecosystem strong and evolving. Their support enables full-time open-source work, new feature development, and community initiatives.\n\nBenefits:\n\n- Prominent logo placement on the AdonisJS website homepage\n- Featured announcement across AdonisJS social and newsletter channels\n- Priority access to roadmap insights and private technical sessions\n- Option to collaborate on ecosystem initiatives",
"amount": 25000,
"currency": "USD",
"frequency": "yearly",
"channels": ["gh-sponsors", "my-paypal"]
}
],
"history": []
}
}
================================================
FILE: index.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { errors as aceErrors } from '@adonisjs/ace'
import { errors as envErrors } from '@adonisjs/env'
import { errors as appErrors } from '@adonisjs/application'
import { errors as encryptionErrors } from '@boringnode/encryption'
import { errors as httpServerErrors } from '@adonisjs/http-server'
export { stubsRoot } from './stubs/main.ts'
export { inject } from './modules/container.ts'
export { Ignitor } from './src/ignitor/main.ts'
export { configProvider } from './src/config_provider.ts'
export { indexEntities } from './src/assembler_hooks/index_entities.ts'
/**
* Aggregated errors from all modules.
*/
export const errors: typeof encryptionErrors &
typeof httpServerErrors &
typeof appErrors &
typeof aceErrors &
typeof envErrors = {
...encryptionErrors,
...httpServerErrors,
...appErrors,
...aceErrors,
...envErrors,
}
/**
* Pretty prints an error with colorful output using
* Youch terminal
*/
export async function prettyPrintError(error: any) {
if (error && typeof error === 'object' && error.code === 'E_DUMP_DIE_EXCEPTION') {
console.error(error)
return
}
try {
const { Youch } = await import('youch')
const youch = new Youch()
console.error(await youch.toANSI(error))
} catch {
console.error(error)
}
}
================================================
FILE: modules/ace/codemods.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { isAbsolute } from 'node:path'
import { EventEmitter } from 'node:events'
import { readFile } from 'node:fs/promises'
import { EnvEditor } from '@adonisjs/env/editor'
import type { UIPrimitives } from '@adonisjs/ace/types'
import type { CodeTransformer } from '@adonisjs/assembler/code_transformer'
import type {
MiddlewareNode,
EnvValidationNode,
BouncerPolicyNode,
SupportedPackageManager,
} from '@adonisjs/assembler/types'
import debug from '../../src/debug.ts'
import type { Application } from '../app.ts'
import stringHelpers from '../../src/helpers/string.ts'
import { type GeneratedStub } from '../../types/app.ts'
/**
* Codemods class for programmatically modifying AdonisJS source files.
* This class provides APIs to modify configuration files, register middleware,
* generate stubs, and install packages.
*
* The codemod APIs rely on the "@adonisjs/assembler" package, which must be
* installed as a dependency in the user application.
*
* @example
* ```ts
* const codemods = new Codemods(app, logger)
*
* // Generate a controller from a stub
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
* filename: 'UserController',
* entity: { name: 'User' }
* })
*
* // Install packages
* await codemods.installPackages([
* { name: '@adonisjs/lucid', isDevDependency: false }
* ])
* ```
*/
export class Codemods extends EventEmitter {
/**
* Reference to lazily imported assembler code transformer
*/
#codeTransformer?: CodeTransformer
/**
* Reference to AdonisJS application
*/
#app: Application<any>
/**
* Reference to CLI logger to write logs
*/
#cliLogger: UIPrimitives['logger']
/**
* Overwrite existing files when generating files
* from stubs
*/
overwriteExisting = false
/**
* Display verbose logs for package installation
*/
verboseInstallOutput = false
constructor(app: Application<any>, cliLogger: UIPrimitives['logger']) {
super()
this.#app = app
this.#cliLogger = cliLogger
}
/**
* - Lazily import the code transformer
* - Return a fresh or reused instance of the code transformer
*/
async #getCodeTransformer() {
try {
if (!this.#codeTransformer) {
const { CodeTransformer } = await import('@adonisjs/assembler/code_transformer')
this.#codeTransformer = new CodeTransformer(this.#app.appRoot)
}
return this.#codeTransformer
} catch {
return null
}
}
/**
* Returns the installation command for different
* package managers
*/
#getInstallationCommands(packages: string[], packageManager: string, isDev: boolean) {
if (!packages.length) {
return ''
}
const colors = this.#cliLogger.getColors()
const devFlag = isDev ? ' -D' : ''
switch (packageManager) {
case 'yarn':
case 'yarn@berry':
return `${colors.yellow(`yarn add${devFlag}`)} ${packages.join(' ')}`
case 'pnpm':
return `${colors.yellow(`pnpm add${devFlag}`)} ${packages.join(' ')}`
case 'npm':
default:
return `${colors.yellow(`npm i${devFlag}`)} ${packages.join(' ')}`
}
}
/**
* Define one or more environment variables in the .env file
*
* @param environmentVariables - Key-value pairs of environment variables
* @param options - Configuration options
* @param options.omitFromExample - Keys to exclude from .env.example file
*
* @example
* ```ts
* await codemods.defineEnvVariables({
* DB_CONNECTION: 'mysql',
* DB_HOST: 'localhost',
* SECRET_KEY: 'abc123'
* }, {
* omitFromExample: ['SECRET_KEY']
* })
* ```
*/
async defineEnvVariables<T extends Record<string, number | string | boolean>>(
environmentVariables: T,
options?: { omitFromExample?: Array<keyof T> }
) {
const editor = new EnvEditor(this.#app.appRoot)
await editor.load()
Object.keys(environmentVariables).forEach((key) => {
const value = environmentVariables[key]
editor.add(key, value, options?.omitFromExample?.includes(key))
})
await editor.save()
this.#cliLogger.action('update .env file').succeeded()
}
/**
* Returns the TsMorph project instance for advanced AST manipulations.
* See https://ts-morph.com/ for documentation.
*
* @example
* ```ts
* const project = await codemods.getTsMorphProject()
* if (project) {
* const sourceFile = project.getSourceFile('app/controllers/user_controller.ts')
* // Perform advanced AST operations
* }
* ```
*/
async getTsMorphProject(): Promise<CodeTransformer['project'] | undefined> {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot create CodeTransformer. Install "@adonisjs/assembler" to modify source files'
)
return
}
return transformer.project
}
/**
* Define validations for the environment variables in the start/env.ts file.
* This method updates the environment validation schema using the assembler.
*
* @param validations - Validation schema node for environment variables
*
* @example
* ```ts
* await codemods.defineEnvValidations({
* NODE_ENV: 'Env.schema.enum(["development", "production", "test"] as const)',
* PORT: 'Env.schema.number()',
* HOST: 'Env.schema.string({ format: "host" })'
* })
* ```
*/
async defineEnvValidations(validations: EnvValidationNode) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "start/env.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update start/env.ts file')
try {
await transformer.defineEnvValidations(validations)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Register middleware in the start/kernel.ts file.
* This method adds middleware to the specified stack (server, router, or named).
*
* @param stack - The middleware stack to register to ('server' | 'router' | 'named')
* @param middleware - Array of middleware nodes to register
*
* @example
* ```ts
* await codemods.registerMiddleware('server', [
* {
* name: 'cors',
* path: '@adonisjs/cors/cors_middleware'
* }
* ])
* ```
*/
async registerMiddleware(stack: 'server' | 'router' | 'named', middleware: MiddlewareNode[]) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "start/kernel.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update start/kernel.ts file')
try {
await transformer.addMiddlewareToStack(stack, middleware)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Register bouncer policies to the list of policies collection exported from
* the "app/policies/main.ts" file. This method adds new policy definitions
* to the policies export.
*
* @param policies - Array of policy nodes to register
*
* @example
* ```ts
* await codemods.registerPolicies([
* {
* name: 'UserPolicy',
* path: '#policies/user_policy'
* }
* ])
* ```
*/
async registerPolicies(policies: BouncerPolicyNode[]) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "app/policies/main.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update app/policies/main.ts file')
try {
await transformer.addPolicies(policies)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Update the adonisrc.ts file with new configuration settings.
* This method allows modification of the AdonisJS runtime configuration.
*
* @param params - Parameters for updating the RC file (varies based on update type)
*
* @example
* ```ts
* await codemods.updateRcFile((rcFile) => {
* rcFile.addCommand('make:custom')
* rcFile.addPreloadFile('#app/events/main')
* })
* ```
*/
async updateRcFile(...params: Parameters<CodeTransformer['updateRcFile']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "adonisrc.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update adonisrc.ts file')
try {
await transformer.updateRcFile(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Register a new Vite plugin in the vite.config.ts file.
* This method adds plugin configuration to the Vite build configuration.
*
* @param params - Parameters for adding the Vite plugin (varies based on plugin type)
*
* @example
* ```ts
* await codemods.registerVitePlugin({
* name: 'vue',
* import: 'import vue from "@vitejs/plugin-vue"',
* options: '()'
* })
* ```
*/
async registerVitePlugin(...params: Parameters<CodeTransformer['addVitePlugin']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "vite.config.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update vite.config.ts file')
try {
await transformer.addVitePlugin(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Register a new Japa plugin in the tests/bootstrap.ts file.
* This method adds plugin configuration to the test runner setup.
*
* @param params - Parameters for adding the Japa plugin (varies based on plugin type)
*
* @example
* ```ts
* await codemods.registerJapaPlugin({
* name: 'expect',
* import: 'import { expect } from "@japa/expect"'
* })
* ```
*/
async registerJapaPlugin(...params: Parameters<CodeTransformer['addJapaPlugin']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update "tests/bootstrap.ts" file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update tests/bootstrap.ts file')
try {
await transformer.addJapaPlugin(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Add a new validator file to the validators directory.
* This method creates a new validator file with the provided definition.
*
* @param params - Parameters for adding the validator
*
* @example
* ```ts
* await codemods.addValidator({
* validatorFileName: 'create_user',
* exportName: 'createUserValidator',
* contents: 'export const createUserValidator = vine.compile(...)'
* })
* ```
*/
async addValidator(...params: Parameters<CodeTransformer['addValidator']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot create validator file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('create validator file')
try {
await transformer.addValidator(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Add a new rate limiter file to the limiters directory.
* This method creates a new limiter file with the provided definition.
*
* @param params - Parameters for adding the limiter
*
* @example
* ```ts
* await codemods.addLimiter({
* limiterFileName: 'api_throttle',
* exportName: 'apiThrottleLimiter',
* contents: 'export const apiThrottleLimiter = limiter.define(...)'
* })
* ```
*/
async addLimiter(...params: Parameters<CodeTransformer['addLimiter']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot create limiter file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('create limiter file')
try {
await transformer.addLimiter(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Add mixins to a model class.
* This method adds mixin calls to the specified model file.
*
* @param params - Parameters for adding model mixins (modelFileName, mixins array)
*
* @example
* ```ts
* await codemods.addModelMixins('user', [
* {
* name: 'SoftDeletes',
* importPath: '@adonisjs/lucid/mixins/soft_deletes',
* importType: 'named'
* }
* ])
* ```
*/
async addModelMixins(...params: Parameters<CodeTransformer['addModelMixins']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update model file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update model file')
try {
await transformer.addModelMixins(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Add a new method to an existing controller class.
* This method injects a new method into the specified controller file.
*
* @param params - Parameters for adding the controller method
*
* @example
* ```ts
* await codemods.addControllerMethod({
* controllerFileName: 'users_controller',
* className: 'UsersController',
* name: 'destroy',
* contents: 'async destroy({ params, response }: HttpContext) { ... }',
* imports: [
* { isType: false, isNamed: true, name: 'HttpContext', path: '@adonisjs/core/http' }
* ]
* })
* ```
*/
async addControllerMethod(...params: Parameters<CodeTransformer['addControllerMethod']>) {
const transformer = await this.#getCodeTransformer()
if (!transformer) {
this.#cliLogger.warning(
'Cannot update controller file. Install "@adonisjs/assembler" to modify source files'
)
return
}
const action = this.#cliLogger.action('update controller file')
try {
await transformer.addControllerMethod(...params)
action.succeeded()
} catch (error) {
this.emit('error', error)
action.failed(error.message)
}
}
/**
* Generate a file using a stub template
*
* @param stubsRoot - Root directory containing stub files
* @param stubPath - Path to the specific stub file
* @param stubState - Template variables for stub generation
*
* @example
* ```ts
* const result = await codemods.makeUsingStub(
* './stubs',
* 'controller.stub',
* {
* filename: 'UserController',
* entity: { name: 'User', modelName: 'User' },
* resourceful: true
* }
* )
* ```
*/
async makeUsingStub(
stubsRoot: string,
stubPath: string,
stubState: Record<string, any>,
options?: {
contentsFromFile?: string
}
): Promise<GeneratedStub> {
const stubs = await this.#app.stubs.create()
const stub = await stubs.build(stubPath, { source: stubsRoot })
/**
* Overwrite the contents of the stub output with the contents
* of the provided file.
*/
if (options?.contentsFromFile) {
const source = isAbsolute(options.contentsFromFile)
? options.contentsFromFile
: this.#app.makePath(options.contentsFromFile)
try {
debug('overwriting stub output with contents from file %s', source)
stub.replaceWith(await readFile(source, 'utf-8'))
} catch (error) {
if (error.code === 'ENOENT') {
throw new Error(
`Cannot replace stub output with "${options.contentsFromFile}" file contents as the file is missing`,
{ cause: error }
)
}
throw error
}
}
const output = await stub.generate({ force: this.overwriteExisting, ...stubState })
debug('generating file %O', output)
const entityFileName = stringHelpers.toUnixSlash(this.#app.relativePath(output.destination))
const result = { ...output, relativeFileName: entityFileName }
if (output.status === 'skipped') {
this.#cliLogger.action(`create ${entityFileName}`).skipped(output.skipReason)
return result
}
this.#cliLogger.action(`create ${entityFileName}`).succeeded()
return result
}
/**
* Install packages using the detected or specified package manager.
* Automatically detects npm, yarn, or pnpm and installs dependencies accordingly.
* You can specify version of each package by setting it in the name like '@adonisjs/lucid'.
*
* @param packages - Array of packages with their dependency type
* @param packageManager - Optional package manager to use (auto-detected if not provided)
*
* @example
* ```ts
* const success = await codemods.installPackages([
* { name: '@adonisjs/lucid', isDevDependency: false },
* { name: '@types/node', isDevDependency: true }
* ])
* ```
*/
async installPackages(
packages: { name: string; isDevDependency: boolean }[],
packageManager?: SupportedPackageManager | 'pnpm@6' | 'deno'
): Promise<boolean> {
const transformer = await this.#getCodeTransformer()
const appPath = this.#app.makePath()
const colors = this.#cliLogger.getColors()
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name)
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name)
if (!transformer) {
this.#cliLogger.warning(
'Cannot install packages. Install "@adonisjs/assembler" or manually install following packages'
)
this.#cliLogger.log(`devDependencies: ${devDependencies.join(',')}`)
this.#cliLogger.log(`dependencies: ${dependencies.join(',')}`)
return false
}
packageManager = packageManager ?? (await transformer.detectPackageManager(appPath)) ?? 'npm'
const spinner = this.#cliLogger.await(`installing dependencies using ${packageManager} `)
const silentLogs = !this.verboseInstallOutput
if (silentLogs) {
spinner.start()
}
try {
if (dependencies.length) {
await transformer.installPackage(dependencies, {
cwd: appPath,
silent: silentLogs,
packageManager,
})
}
if (devDependencies.length) {
await transformer.installPackage(devDependencies, {
dev: true,
cwd: appPath,
silent: silentLogs,
packageManager,
})
}
if (silentLogs) {
spinner.stop()
}
this.#cliLogger.success('Packages installed')
this.#cliLogger.log(
devDependencies.map((dependency) => ` ${colors.dim('dev')} ${dependency} `).join('\n')
)
this.#cliLogger.log(
dependencies.map((dependency) => ` ${colors.dim('prod')} ${dependency} `).join('\n')
)
return true
} catch (error) {
if (silentLogs) {
spinner.update('unable to install dependencies')
spinner.stop()
}
this.#cliLogger.fatal(error)
this.emit('error', error)
return false
}
}
/**
* List the packages that should be installed manually.
* This method displays installation commands for different package managers
* when automatic installation is not available or desired.
*
* @param packages - Array of packages with their dependency type
*
* @example
* ```ts
* await codemods.listPackagesToInstall([
* { name: '@adonisjs/lucid', isDevDependency: false },
* { name: '@types/node', isDevDependency: true }
* ])
* // Output:
* // Please install following packages
* // npm i -D @types/node
* // npm i @adonisjs/lucid
* ```
*/
async listPackagesToInstall(packages: { name: string; isDevDependency: boolean }[]) {
const appPath = this.#app.makePath()
const devDependencies = packages.filter((pkg) => pkg.isDevDependency).map(({ name }) => name)
const dependencies = packages.filter((pkg) => !pkg.isDevDependency).map(({ name }) => name)
let packageManager: string | null = null
const transformer = await this.#getCodeTransformer()
if (transformer) packageManager = await transformer.detectPackageManager(appPath)
this.#cliLogger.log('Please install following packages')
this.#cliLogger.log(
this.#getInstallationCommands(devDependencies, packageManager || 'npm', true)
)
this.#cliLogger.log(this.#getInstallationCommands(dependencies, packageManager || 'npm', false))
}
}
================================================
FILE: modules/ace/commands.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BaseCommand as AceBaseCommand, ListCommand as AceListCommand } from '@adonisjs/ace'
import { type Kernel } from './kernel.ts'
import type { ApplicationService } from '../../src/types.ts'
import type { CommandOptions, ParsedOutput, UIPrimitives } from '../../types/ace.ts'
/**
* The base command class for creating custom Ace commands in AdonisJS applications.
* This class extends the base Ace command with AdonisJS-specific functionality like
* dependency injection and application lifecycle management.
*
* @example
* ```ts
* export default class MakeUser extends BaseCommand {
* static commandName = 'make:user'
* static description = 'Create a new user'
*
* async run() {
* this.logger.info('Creating user...')
* // Command implementation
* }
* }
* ```
*/
export class BaseCommand extends AceBaseCommand {
static options: CommandOptions = {}
get staysAlive() {
return (this.constructor as typeof BaseCommand).options.staysAlive
}
get startApp() {
return (this.constructor as typeof BaseCommand).options.startApp
}
constructor(
public app: ApplicationService,
public kernel: Kernel,
parsed: ParsedOutput,
ui: UIPrimitives,
prompt: Kernel['prompt']
) {
super(kernel, parsed, ui, prompt)
}
/**
* Creates the codemods module to modify source files programmatically.
* This method provides access to AST-based code transformations.
*
* @example
* ```ts
* const codemods = await this.createCodemods()
* await codemods.makeUsingStub(stubsRoot, 'controller.stub', {
* filename: 'UserController',
* entity: { name: 'User' }
* })
* ```
*/
async createCodemods() {
const { Codemods } = await import('./codemods.js')
const codemods = new Codemods(this.app, this.logger)
codemods.on('error', () => {
this.exitCode = 1
})
return codemods
}
/**
* The prepare template method is used to prepare the
* state for the command. This is the first method
* executed on a given command instance.
*/
prepare?(..._: any[]): any
/**
* The interact template method is used to display the prompts
* to the user. The method is called after the prepare
* method.
*/
interact?(..._: any[]): any
/**
* The completed method is the method invoked after the command
* finishes or results in an error.
*
* You can access the command error using the `this.error` property.
* Returning `true` from completed method supresses the error
* reporting to the kernel layer.
*/
completed?(..._: any[]): any
/**
* Executes the lifecycle hooks and the run method from the command
*/
async exec() {
this.hydrate()
try {
/**
* Executing the template methods
*/
this.prepare && (await this.app.container.call<any, 'prepare'>(this, 'prepare'))
this.interact && (await this.app.container.call<any, 'interact'>(this, 'interact'))
const result = await this.app.container.call<BaseCommand, 'run'>(this, 'run')
/**
* Set exit code
*/
this.result = this.result === undefined ? result : this.result
this.exitCode = this.exitCode ?? 0
} catch (error) {
this.error = error
this.exitCode = this.exitCode ?? 1
}
/**
* Run the completed method (if exists) and check if has handled
* the error
*/
let errorHandled = this.completed
? await this.app.container.call<any, 'completed'>(this, 'completed')
: false
if (this.error && !errorHandled) {
await this.kernel.errorHandler.render(this.error, this.kernel)
}
return this.result
}
/**
* Terminate the application gracefully. This method should be preferred over
* calling `app.terminate()` directly as it only triggers termination when
* the current command is the main command responsible for the process.
*
* @example
* ```ts
* export default class SomeCommand extends BaseCommand {
* async run() {
* // Do some work
* await this.terminate()
* }
* }
* ```
*/
async terminate() {
if (this.kernel.getMainCommand() === this) {
await this.app.terminate()
}
}
}
/**
* The List command is used to display a list of available commands.
* This command extends the base Ace ListCommand with AdonisJS-specific functionality.
*/
export class ListCommand extends AceListCommand implements BaseCommand {
static options: CommandOptions = {}
get staysAlive() {
return (this.constructor as typeof BaseCommand).options.staysAlive
}
get startApp() {
return (this.constructor as typeof BaseCommand).options.startApp
}
constructor(
public app: ApplicationService,
public kernel: Kernel,
parsed: ParsedOutput,
ui: UIPrimitives,
prompt: Kernel['prompt']
) {
super(kernel, parsed, ui, prompt)
}
/**
* Auto-select JSON output when running inside an AI agent
* and no explicit format flag is provided.
*/
async run() {
if (!this.json && this.app.runningInAIAgent) {
this.json = true
}
return super.run()
}
/**
* Creates the codemods module to modify source files programmatically.
* This method provides access to AST-based code transformations.
*/
async createCodemods() {
const { Codemods } = await import('./codemods.js')
return new Codemods(this.app, this.logger)
}
/**
* Terminate the app. A command should prefer calling this method
* over the "app.terminate", because this method only triggers
* app termination when the current command is in the charge
* of the process.
*/
async terminate() {
if (this.kernel.getMainCommand() === this) {
await this.app.terminate()
}
}
}
================================================
FILE: modules/ace/create_kernel.ts
================================================
/*
* @adonisjs/ace
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Kernel } from './main.ts'
import type { ApplicationService } from '../../src/types.ts'
import { FsLoader, HelpCommand, type BaseCommand } from '../../modules/ace/main.ts'
/**
* Create and configure an Ace command kernel for AdonisJS applications.
* This function abstracts the kernel setup logic and can be used in different
* environments with appropriate configurations.
*
* - In console environment, Ace manages the lifecycle of the process
* - In other environments, Ace can be pulled from the container to run commands
*
* @param app - The AdonisJS application service instance
* @param commandName - Optional specific command name for optimized loading
*
* @example
* ```ts
* const app = new Application(new URL('../', import.meta.url))
* const kernel = createAceKernel(app)
*
* // Run a specific command
* await kernel.handle(['make:controller', 'UserController'])
* ```
*/
export function createAceKernel(app: ApplicationService, commandName?: string) {
const kernel = new Kernel(app)
kernel.info.set('binary', 'node ace')
/**
* Lazy import commands mentioned in the "commands" array
* of rcFile
*/
app.rcFile.commands.forEach((commandModule) => {
kernel.addLoader(() =>
typeof commandModule === 'function' ? commandModule() : app.import(commandModule)
)
})
/**
* When we know the command we are running ahead of time, then we
* defer loading the application commands if the command has
* already been registered by other loaders.
*/
const fsLoader = new FsLoader<typeof BaseCommand>(app.commandsPath())
kernel.addLoader({
async getMetaData() {
if (!commandName || !kernel.getCommand(commandName)) {
return fsLoader.getMetaData()
}
return []
},
getCommand(command) {
return fsLoader.getCommand(command)
},
})
/**
* Custom global flags
*/
kernel.defineFlag('ansi', {
type: 'boolean',
showNegatedVariantInHelp: true,
description: 'Force enable or disable colorful output',
})
kernel.defineFlag('help', {
type: 'boolean',
description: HelpCommand.description,
})
/**
* Flag listener to turn colors on/off
*/
kernel.on('ansi', (_, $kernel, parsed) => {
if (parsed.flags.ansi === false) {
$kernel.ui.switchMode('silent')
}
if (parsed.flags.ansi === true) {
$kernel.ui.switchMode('normal')
}
})
/**
* Flag listener to display the help
*/
kernel.on('help', async (command, $kernel, parsed) => {
parsed.args.unshift(command.commandName)
const help = new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt)
await help.exec()
return $kernel.shortcircuit()
})
return kernel
}
================================================
FILE: modules/ace/kernel.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Kernel as AceKernel } from '@adonisjs/ace'
import { type BaseCommand, ListCommand } from './commands.ts'
import type { ApplicationService } from '../../src/types.ts'
/**
* The Ace command kernel for AdonisJS applications. This kernel extends the base
* Ace kernel with AdonisJS-specific functionality like dependency injection and
* application lifecycle management.
*
* @example
* ```ts
* const app = new Application(new URL('../', import.meta.url))
* const kernel = new Kernel(app)
*
* await kernel.handle(['make:controller', 'UserController'])
* ```
*/
export class Kernel extends AceKernel<typeof BaseCommand> {
/**
* Create a new Ace kernel instance
*
* @param app - The AdonisJS application instance
*/
constructor(public app: ApplicationService) {
super(ListCommand, {
create: async (command, parsedOutput, $kernel) => {
return app.container.make(command, [app, $kernel, parsedOutput, $kernel.ui, $kernel.prompt])
},
run: (command) => command.exec(),
})
}
}
================================================
FILE: modules/ace/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Ace command line interface module for AdonisJS applications.
* Provides the kernel, base commands, and utilities for building CLI applications.
*
* @example
* // Create and use the Ace kernel
* import { Kernel, BaseCommand } from '@adonisjs/core/ace'
*
* const kernel = new Kernel(app)
* await kernel.handle(['make:controller', 'UserController'])
*
* @example
* // Create a custom command
* import { BaseCommand, args, flags } from '@adonisjs/core/ace'
*
* export default class MakeUser extends BaseCommand {
* static commandName = 'make:user'
* static description = 'Create a new user'
*
* @args.string({ description: 'Name of the user' })
* declare name: string
*
* @flags.boolean({ description: 'Create admin user' })
* declare admin: boolean
*
* async run() {
* this.logger.info(`Creating user: ${this.name}`)
* }
* }
*/
export { Kernel } from './kernel.ts'
export { BaseCommand, ListCommand } from './commands.ts'
export {
args,
flags,
errors,
Parser,
FsLoader,
ListLoader,
cliHelpers,
HelpCommand,
IndexGenerator,
tracingChannels,
} from '@adonisjs/ace'
================================================
FILE: modules/app.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Application module re-exports all functionality from @adonisjs/application.
* This includes the main Application class and related types for managing
* the AdonisJS application lifecycle, container bindings, and service providers.
*
* @example
* // Import the Application class
* import { Application } from '@adonisjs/core/app'
*
* const app = new Application(new URL('../', import.meta.url))
* await app.init()
* await app.boot()
*
* @example
* // Import application types
* import type { ApplicationService, ContainerBindings } from '@adonisjs/core/app'
*/
export * from '@adonisjs/application'
================================================
FILE: modules/bodyparser/bodyparser_middleware.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BodyParserMiddleware } from '@adonisjs/bodyparser/bodyparser_middleware'
/**
* Default export allows lazy importing middleware with
* destructuring the named exports
*/
export default BodyParserMiddleware
================================================
FILE: modules/bodyparser/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/bodyparser'
================================================
FILE: modules/config.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Configuration module re-exports all functionality from @adonisjs/config.
* This includes the Config class and related types for managing application
* configuration files and environment-specific settings.
*
* @example
* // Import the Config class
* import { Config } from '@adonisjs/core/config'
*
* const config = new Config()
* config.set('database.connection', 'mysql')
* const dbConnection = config.get('database.connection')
*
* @example
* // Import configuration types
* import type { ConfigProvider } from '@adonisjs/core/config'
*/
export * from '@adonisjs/config'
================================================
FILE: modules/container.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/fold'
================================================
FILE: modules/dumper/define_config.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { type ConsoleDumpConfig } from '@poppinss/dumper/console/types'
import { type HTMLDumpConfig } from '@poppinss/dumper/html/types'
/**
* Define configuration for the dumper service exported by the
* "@adonisjs/core/services/dumper" module. This function allows
* you to customize HTML and console output formatting options.
*
* @param dumperConfig - Configuration object with HTML and console options
* @param dumperConfig.html - HTML output formatting configuration
* @param dumperConfig.console - Console output formatting configuration
*
* @example
* ```ts
* export default defineConfig({
* html: {
* showHidden: true,
* depth: 5,
* colors: true
* },
* console: {
* showHidden: false,
* depth: 3,
* collapse: ['Date', 'DateTime']
* }
* })
* ```
*/
export function defineConfig(
dumperConfig: Partial<{ html: HTMLDumpConfig; console: ConsoleDumpConfig }>
) {
return dumperConfig
}
================================================
FILE: modules/dumper/dumper.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import useColors from '@poppinss/colors'
import { dump as consoleDump } from '@poppinss/dumper/console'
import type { HTMLDumpConfig } from '@poppinss/dumper/html/types'
import type { ConsoleDumpConfig } from '@poppinss/dumper/console/types'
import { createScript, createStyleSheet, dump } from '@poppinss/dumper/html'
import type { Application } from '../app.ts'
import { E_DUMP_DIE_EXCEPTION } from './errors.ts'
const colors = useColors.ansi()
const DUMP_TITLE_STYLES = `
.adonisjs-dump-header {
font-family: JetBrains Mono, monaspace argon, Menlo, Monaco, Consolas, monospace;
background: #ff1639;
border-radius: 4px;
color: #fff;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
padding: 0.4rem 1.2rem;
font-size: 1em;
display: flex;
justify-content: space-between;
}
.adonisjs-dump-header .adonisjs-dump-header-title {
font-weight: bold;
text-transform: uppercase;
}
.adonisjs-dump-header .adonisjs-dump-header-source {
font-weight: bold;
color: inherit;
text-decoration: underline;
}
.dumper-dump pre {
border-radius: 4px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}`
const IDE = process.env.ADONIS_IDE ?? process.env.EDITOR ?? ''
/**
* Dumper exposes the API to dump or die/dump values in your
* AdonisJS application. An singleton instance of the Dumper
* is shared as a service and may use it follows.
*
* ```ts
* const dumper = container.make('dumper')
*
* dumper.configureHtmlOutput({
* // parser + html formatter config
* })
*
* dumper.configureAnsiOutput({
* // parser + console formatter config
* })
*
* const html = dumper.dumpToHtml(value)
* const ansi = dumper.dumpToAnsi(value)
*
* // Returns style and script tags that must be
* // injeted to the head of the HTML document
*
* const head = dumper.getHeadElements()
* ```
*/
export class Dumper {
#app: Application<any>
/**
* Configuration for the HTML formatter
*/
#htmlConfig: HTMLDumpConfig = {}
/**
* Configuration for the Console formatter
*/
#consoleConfig: ConsoleDumpConfig = {
collapse: ['DateTime', 'Date'],
}
/**
* A collections of known editors to create URLs to open
* them
*/
#editors: Record<string, string> = {
textmate: 'txmt://open?url=file://%f&line=%l',
macvim: 'mvim://open?url=file://%f&line=%l',
emacs: 'emacs://open?url=file://%f&line=%l',
sublime: 'subl://open?url=file://%f&line=%l',
phpstorm: 'phpstorm://open?file=%f&line=%l',
atom: 'atom://core/open/file?filename=%f&line=%l',
vscode: 'vscode://file/%f:%l',
}
/**
* Creates a new Dumper instance
*
* @param app - The AdonisJS application instance
*/
constructor(app: Application<any>) {
this.#app = app
}
/**
* Returns the link to open the file using dd inside one
* of the known code editors. Constructs a URL that can be used
* to open the file at a specific line in supported editors.
*
* @param source - Optional source file information
* @param source.location - The file path to open
* @param source.line - The line number to jump to
*/
#getEditorLink(source?: {
location: string
line: number
}): { href: string; text: string } | undefined {
const editorURL = this.#editors[IDE] || IDE
if (!editorURL || !source) {
return
}
return {
href: editorURL.replace('%f', source.location).replace('%l', String(source.line)),
text: `${this.#app.relativePath(source.location)}:${source.line}`,
}
}
/**
* Configure the HTML formatter output options
*
* @param config - Configuration options for HTML dump formatting
*
* @example
* ```ts
* dumper.configureHtmlOutput({
* showHidden: true,
* depth: 5,
* colors: false
* })
* ```
*/
configureHtmlOutput(config: HTMLDumpConfig): this {
this.#htmlConfig = config
return this
}
/**
* Configure the ANSI formatter output options for console display
*
* @param config - Configuration options for ANSI console formatting
*
* @example
* ```ts
* dumper.configureAnsiOutput({
* showHidden: true,
* depth: 3,
* collapse: ['Date', 'DateTime']
* })
* ```
*/
configureAnsiOutput(config: ConsoleDumpConfig): this {
this.#consoleConfig = config
return this
}
/**
* Returns the style and script elements that need to be injected into
* the HTML document head for proper dump visualization
*
* @param cspNonce - Optional Content Security Policy nonce for inline scripts
*
* @example
* ```ts
* const headElements = dumper.getHeadElements('abc123')
* // Insert into your HTML head section
* ```
*/
getHeadElements(cspNonce?: string): string {
return (
`<style id="dumper-styles">` +
createStyleSheet() +
DUMP_TITLE_STYLES +
'</style>' +
`<script id="dumper-script"${cspNonce ? ` nonce="${cspNonce}"` : ''}>` +
createScript() +
'</script>'
)
}
/**
* Dump a value to formatted HTML output
*
* @param value - The value to dump and inspect
* @param options - Options for HTML output formatting
* @param options.cspNonce - Optional Content Security Policy nonce
* @param options.title - Optional title to display in the dump header
* @param options.source - Optional source file information for editor links
*
* @example
* ```ts
* const htmlOutput = dumper.dumpToHtml(user, {
* title: 'User Object',
* source: { location: '/app/controllers/user.ts', line: 42 }
* })
* ```
*/
dumpToHtml(
value: unknown,
options: {
cspNonce?: string
title?: string
source?: {
location: string
line: number
}
} = {}
) {
const link = this.#getEditorLink(options.source) ?? null
const title = options.title || 'DUMP'
return (
'<div class="adonisjs-dump-header">' +
`<span class="adonisjs-dump-header-title">${title}</span>` +
(link ? `<a href="${link.href}" class="adonisjs-dump-header-source">${link.text}</a>` : '') +
'</div>' +
dump(value, { cspNonce: options.cspNonce, ...this.#htmlConfig })
)
}
/**
* Dump a value to formatted ANSI output for console display
*
* @param value - The value to dump and inspect
* @param options - Options for ANSI output formatting
* @param options.title - Optional title to display in the dump header
* @param options.source - Optional source file information for editor links
*
* @example
* ```ts
* const ansiOutput = dumper.dumpToAnsi(user, {
* title: 'User Debug',
* source: { location: '/app/controllers/user.ts', line: 42 }
* })
* console.log(ansiOutput)
* ```
*/
dumpToAnsi(
value: unknown,
options: {
title?: string
source?: {
location: string
line: number
}
} = {}
) {
const columns = process.stdout.columns
/**
* Link to the source file
*/
const link = `${this.#getEditorLink(options.source)?.text ?? ''} `
/**
* Dump title
*/
const title = ` ${options.title || 'DUMP'}`
/**
* Whitespace between the title and the link to align them
* on each side of x axis
*/
const whiteSpaceLength = columns ? columns - link.length - title.length - 4 : 2
const whiteSpace = new Array(whiteSpaceLength <= 0 ? 2 : whiteSpaceLength).join(' ')
/**
* Styled heading with background color and bold text
*/
const heading = colors.bgRed().bold(`${title}${whiteSpace}${link}`)
return `${heading}\n${consoleDump(value, this.#consoleConfig)}`
}
/**
* Dump values and die. This method dumps the provided value and then
* terminates the application. The output format is automatically chosen
* based on the execution context.
*
* - During an HTTP request, HTML output will be sent to the browser
* - Otherwise the value will be logged to the console in ANSI format
*
* @param value - The value to dump before terminating
* @param traceSourceIndex - Stack trace index for source location (default: 1)
*
* @example
* ```ts
* // This will dump the user object and terminate the application
* dumper.dd(user)
*
* // This will never execute
* console.log('This line will not run')
* ```
*/
dd(value: unknown, traceSourceIndex: number = 1) {
const error = new E_DUMP_DIE_EXCEPTION(value, this)
error.setTraceSourceIndex(traceSourceIndex)
throw error
}
}
================================================
FILE: modules/dumper/errors.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { inspect } from 'node:util'
import { parse } from 'error-stack-parser-es'
import { Exception } from '@poppinss/utils/exception'
import type { Dumper } from './dumper.ts'
import type { Kernel } from '../ace/kernel.ts'
import type { HttpContext } from '../http/main.ts'
/**
* DumpDie exception raised by the "dd" (dump and die) function.
* This special exception terminates execution while dumping the provided
* value as HTML (during HTTP requests) or ANSI (in console/CLI).
*
* @example
* ```ts
* // This will dump the user object and terminate
* dumper.dd(user)
*
* // In HTTP context: sends HTML dump to browser
* // In CLI context: prints ANSI dump to console
* ```
*/
class DumpDieException extends Exception {
static status: number = 500
static code: string = 'E_DUMP_DIE_EXCEPTION'
declare fileName: string
declare lineNumber: number
#dumper: Dumper
#traceSourceIndex: number = 1
value: unknown
constructor(value: unknown, dumper: Dumper) {
super('Dump and Die exception')
this.#dumper = dumper
this.value = value
}
/**
* Returns the source file and line number location for the error
*/
#getErrorSource(): { location: string; line: number } | undefined {
if (this.fileName && this.lineNumber) {
return {
location: this.fileName,
line: this.lineNumber,
}
}
const source = parse(this)[this.#traceSourceIndex]
if (!source.fileName || !source.lineNumber) {
return
}
return {
location: source.fileName,
line: source.lineNumber,
}
}
/**
* Set the stack trace index for determining the source location.
* This is useful when building nested helpers on top of dump/die functionality.
*
* @param index - Stack trace index (0 = current function, 1 = caller, etc.)
*/
setTraceSourceIndex(index: number) {
this.#traceSourceIndex = index
return this
}
/**
* Preventing itself from getting reported by the
* AdonisJS exception reporter
*/
report() {}
/**
* HTTP exception handler that renders the dump as HTML output.
* This method is called automatically by AdonisJS when a DumpDieException
* is thrown during an HTTP request.
*
* @param error - The DumpDieException instance
* @param ctx - HTTP context for the current request
*/
async handle(error: DumpDieException, ctx: HttpContext) {
const source = this.#getErrorSource()
/**
* Comes from the shield package
*/
const cspNonce = 'nonce' in ctx.response ? (ctx.response.nonce as string) : undefined
ctx.response
.status(500)
.send(
'<!DOCTYPE html>' +
'<html>' +
'<head>' +
'<meta charset="utf-8">' +
'<meta name="viewport" content="width=device-width">' +
`${this.#dumper.getHeadElements(cspNonce)}` +
'</head>' +
'<body>' +
`${this.#dumper.dumpToHtml(error.value, { cspNonce, source, title: 'DUMP DIE' })}` +
'</body>' +
'</html>'
)
}
/**
* Ace command exception handler that renders the dump as ANSI output.
* This method is called automatically by the Ace kernel when a DumpDieException
* is thrown during command execution.
*
* @param error - The DumpDieException instance
* @param kernel - Ace kernel instance
*/
async render(error: DumpDieException, kernel: Kernel) {
const source = this.#getErrorSource()
kernel.ui.logger.log(this.#dumper.dumpToAnsi(error.value, { source, title: 'DUMP DIE' }))
}
/**
* Custom output for the Node.js util inspect
*/
[inspect.custom]() {
const source = this.#getErrorSource()
return this.#dumper.dumpToAnsi(this.value, { source, title: 'DUMP DIE' })
}
}
export const E_DUMP_DIE_EXCEPTION = DumpDieException
================================================
FILE: modules/dumper/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Dumper module provides debugging and inspection utilities for AdonisJS applications.
* Includes the Dumper class for formatting output, error classes, and configuration helpers.
*
* @example
* // Use the dumper service
* import { Dumper } from '@adonisjs/core/dumper'
*
* const dumper = new Dumper(app)
* const htmlOutput = dumper.dumpToHtml(user, { title: 'User Data' })
* const ansiOutput = dumper.dumpToAnsi(user, { title: 'Debug User' })
*
* @example
* // Configure dumper output
* import { defineConfig } from '@adonisjs/core/dumper'
*
* export default defineConfig({
* html: { showHidden: true, depth: 5 },
* console: { collapse: ['Date', 'DateTime'] }
* })
*/
export * as errors from './errors.ts'
export { Dumper } from './dumper.ts'
export { defineConfig } from './define_config.ts'
================================================
FILE: modules/dumper/plugins/edge.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { type Edge, Template } from 'edge.js'
import { type Dumper } from '../dumper.ts'
/**
* Returns an edge plugin that integrates with a given
* dumper instance
*/
export function pluginEdgeDumper(dumper: Dumper) {
Template.macro('dumper' as any, dumper)
return (edge: Edge) => {
edge.registerTag({
tagName: 'dump',
block: false,
seekable: true,
noNewLine: true,
compile(parser, buffer, token) {
const parsed = parser.utils.transformAst(
parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename),
token.filename,
parser
)
buffer.writeExpression(
`template.stacks.pushOnceTo('dumper', 'dumper_globals', template.dumper.getHeadElements(state.cspNonce))`,
token.filename,
token.loc.start.line
)
buffer.outputExpression(
`template.dumper.dumpToHtml(${parser.utils.stringify(parsed)}, { cspNonce: state.cspNonce, source: { location: $filename, line: $lineNumber } })`,
token.filename,
token.loc.start.line,
true
)
},
})
edge.registerTag({
tagName: 'dd',
block: false,
seekable: true,
noNewLine: true,
compile(parser, buffer, token) {
const parsed = parser.utils.transformAst(
parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename),
token.filename,
parser
)
/**
* Dump/Die statement to catch error and convert it into
* an Edge error
*/
const ddStatement = [
'try {',
` template.dumper.dd(${parser.utils.stringify(parsed)})`,
'} catch (error) {',
` if (error.code === 'E_DUMP_DIE_EXCEPTION') {`,
' const edgeError = template.createError(error.message, $filename, $lineNumber)',
' error.fileName = $filename',
' error.lineNumber = $lineNumber',
' edgeError.handle = function (_, ctx) {',
' return error.handle(error, ctx)',
' }',
' edgeError.report = function () {',
' return error.report(error)',
' }',
' throw edgeError',
' }',
' throw error',
'}',
].join('\n')
buffer.writeStatement(ddStatement, token.filename, token.loc.start.line)
},
})
}
}
================================================
FILE: modules/encryption/define_config.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import debug from '../../src/debug.ts'
import { configProvider } from '../../src/config_provider.ts'
import { type ConfigProvider } from '../../src/types.ts'
import {
type AESSIVDriverConfig,
type AES256CBCDriverConfig,
type AES256GCMDriverConfig,
type ChaCha20Poly1305DriverConfig,
type LegacyDriverConfig,
} from '../../types/encryption.ts'
import { type EncryptionConfig } from '../../types/encryption.ts'
import { InvalidArgumentsException } from '../../src/exceptions.ts'
/**
* Resolved configuration from the config provider that will be
* accepted by the encryption manager.
*
* This type unwraps ConfigProvider types to their resolved values,
* ensuring all encryptors in the list are concrete EncryptionConfig
* objects rather than providers.
*
* @template KnownEncryptors - Record of encryptor names to their configurations
*/
type ResolvedConfig<
KnownEncryptors extends Record<string, EncryptionConfig | ConfigProvider<EncryptionConfig>>,
> = {
/**
* The default encryptor name to use when no specific
* encryptor is requested
*/
default?: keyof KnownEncryptors
/**
* Map of encryptor names to their resolved configurations.
* ConfigProvider types are unwrapped to their underlying
* EncryptionConfig values.
*/
list: {
[K in keyof KnownEncryptors]: KnownEncryptors[K] extends ConfigProvider<infer A>
? A
: KnownEncryptors[K]
}
}
/**
* Defines the encryption configuration for the application.
*
* This function creates a configuration provider that lazily resolves
* encryption drivers. It validates that the default encryptor (if specified)
* exists in the list and resolves any ConfigProvider instances to their
* concrete values.
*
* @template KnownEncryptors - Record of encryptor names to their configurations
*
* @param config - The encryption configuration object
* @param config.default - Optional default encryptor name
* @param config.list - Map of encryptor names to their configurations or providers
*
* @example
* ```ts
* const encryptionConfig = defineConfig({
* default: 'app',
* list: {
* app: drivers.aes256gcm({
* id: 'app',
* keys: [env.get('APP_KEY')]
* }),
* backup: drivers.chacha20({
* id: 'backup',
* keys: [env.get('BACKUP_KEY')]
* })
* }
* })
* ```
*/
export function defineConfig<
KnownEncryptors extends Record<string, EncryptionConfig | ConfigProvider<EncryptionConfig>>,
>(config: {
default?: keyof KnownEncryptors
list: KnownEncryptors
}): ConfigProvider<ResolvedConfig<KnownEncryptors>> {
/**
* Encryption list should always be provided
*/
if (!config.list) {
throw new InvalidArgumentsException('Missing "list" property in encryption config')
}
/**
* The default encryption should be mentioned in the list
*/
if (config.default && !config.list[config.default]) {
throw new InvalidArgumentsException(
`Missing "list.${String(
config.default
)}" in encryption config. It is referenced by the "default" property`
)
}
/**
* Config provider to lazily import drivers as they are used inside
* the user application
*/
return configProvider.create<ResolvedConfig<KnownEncryptors>>(async (app) => {
debug('resolving encryption config')
const encryptorsList = Object.keys(config.list)
const encryptors = {} as Record<string, EncryptionConfig | ConfigProvider<EncryptionConfig>>
for (let encryptorName of encryptorsList) {
const encryptor = config.list[encryptorName]
if ('resolver' in encryptor) {
encryptors[encryptorName] = await encryptor.resolver(app)
} else {
encryptors[encryptorName] = encryptor
}
}
return {
default: config.default,
list: encryptors as ResolvedConfig<KnownEncryptors>['list'],
}
})
}
/**
* Collection of encryption driver factory functions.
*
* Each driver factory creates a ConfigProvider that lazily imports
* and configures the corresponding encryption driver. This allows
* for efficient code splitting and on-demand loading of encryption
* algorithms.
*/
export const drivers: {
/**
* Creates a ChaCha20-Poly1305 encryption driver configuration.
*
* ChaCha20-Poly1305 is a modern authenticated encryption algorithm
* that provides excellent performance on systems without AES hardware
* acceleration.
*
* @param config - The ChaCha20-Poly1305 driver configuration
*
* @example
* ```ts
* drivers.chacha20({
* id: 'app',
* keys: [env.get('APP_KEY')]
* })
* ```
*/
chacha20: (config: ChaCha20Poly1305DriverConfig) => ConfigProvider<EncryptionConfig>
/**
* Creates an AES-256-CBC encryption driver configuration.
*
* AES-256-CBC is a widely-supported block cipher mode. However,
* consider using AES-256-GCM for new applications as it provides
* authenticated encryption.
*
* @param config - The AES-256-CBC driver configuration
*
* @example
* ```ts
* drivers.aes256cbc({
* id: 'legacy',
* keys: [env.get('LEGACY_KEY')]
* })
* ```
*/
aes256cbc: (config: AES256CBCDriverConfig) => ConfigProvider<EncryptionConfig>
/**
* Creates an AES-256-GCM encryption driver configuration.
*
* AES-256-GCM is an authenticated encryption algorithm that provides
* both confidentiality and integrity. It offers excellent performance
* on systems with AES hardware acceleration.
*
* @param config - The AES-256-GCM driver configuration
*
* @example
* ```ts
* drivers.aes256gcm({
* id: 'app',
* keys: [env.get('APP_KEY')]
* })
* ```
*/
aes256gcm: (config: AES256GCMDriverConfig) => ConfigProvider<EncryptionConfig>
/**
* Creates an AES-SIV encryption driver configuration.
*
* @param config - The AES-SIV driver configuration
*
* @example
* ```ts
* drivers.aessiv({
* id: 'app',
* key: env.get('APP_KEY')
* })
* ```
*/
aessiv: (config: AESSIVDriverConfig) => ConfigProvider<EncryptionConfig>
/**
* Creates a Legacy encryption driver configuration.
*
* The Legacy driver maintains compatibility with the old AdonisJS v6
* encryption format. It uses AES-256-CBC with HMAC SHA-256.
*
* Use this driver to decrypt values encrypted with older versions
* of AdonisJS or when migrating to newer encryption drivers.
*
* @param config - The Legacy driver configuration
*
* @example
* ```ts
* drivers.legacy({
* keys: [env.get('APP_KEY')]
* })
* ```
*/
legacy: (config: LegacyDriverConfig) => ConfigProvider<EncryptionConfig>
} = {
chacha20: (config) => {
return configProvider.create(async () => {
const { ChaCha20Poly1305 } = await import('./drivers/chacha20_poly1305.ts')
debug('configuring chacha20 encryption driver')
return {
driver: (key) => new ChaCha20Poly1305({ id: config.id, key }),
keys: config.keys.filter((key) => !!key),
}
})
},
aes256cbc: (config) => {
return configProvider.create(async () => {
const { AES256CBC } = await import('./drivers/aes_256_cbc.ts')
debug('configuring aes256cbc encryption driver')
return {
driver: (key) => new AES256CBC({ id: config.id, key }),
keys: config.keys.filter((key) => !!key),
}
})
},
aes256gcm: (config) => {
return configProvider.create(async () => {
const { AES256GCM } = await import('./drivers/aes_256_gcm.ts')
debug('configuring aes256gcm encryption driver')
return {
driver: (key) => new AES256GCM({ id: config.id, key }),
keys: config.keys.filter((key) => !!key),
}
})
},
aessiv: (config) => {
return configProvider.create(async () => {
const { AESSIV } = await import('./drivers/aes_siv.ts')
debug('configuring aessiv encryption driver')
return {
driver: (key) => new AESSIV({ id: config.id, key }),
keys: [config.key].filter((key) => !!key),
}
})
},
legacy: (config) => {
return configProvider.create(async () => {
const { Legacy } = await import('./drivers/legacy.ts')
debug('configuring legacy encryption driver')
return {
driver: (key) => new Legacy({ key }),
keys: config.keys.filter((key) => !!key),
}
})
},
}
================================================
FILE: modules/encryption/drivers/aes_256_cbc.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* AES-256-CBC encryption driver implementation.
*
* This driver provides encryption and decryption using the AES-256-CBC
* (Advanced Encryption Standard with 256-bit key in Cipher Block Chaining mode)
* algorithm. While widely supported, AES-256-CBC does not provide authenticated
* encryption. Consider using AES-256-GCM for new applications.
*
* @example
* ```ts
* const driver = new AES256CBC({
* id: 'app',
* key: 'your-256-bit-key-here'
* })
*
* const encrypted = driver.encrypt('sensitive data')
* const decrypted = driver.decrypt(encrypted)
* ```
*/
export { AES256CBC } from '@boringnode/encryption/drivers/aes_256_cbc'
================================================
FILE: modules/encryption/drivers/aes_256_gcm.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* AES-256-GCM encryption driver implementation.
*
* This driver provides authenticated encryption and decryption using the
* AES-256-GCM (Advanced Encryption Standard with 256-bit key in Galois/Counter Mode)
* algorithm. GCM mode provides both confidentiality and authenticity, making it
* the recommended choice for modern applications. It offers excellent performance
* on systems with AES hardware acceleration.
*
* @example
* ```ts
* const driver = new AES256GCM({
* id: 'app',
* key: 'your-256-bit-key-here'
* })
*
* const encrypted = driver.encrypt('sensitive data')
* const decrypted = driver.decrypt(encrypted)
* ```
*/
export { AES256GCM } from '@boringnode/encryption/drivers/aes_256_gcm'
================================================
FILE: modules/encryption/drivers/aes_siv.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* AES-SIV encryption driver implementation.
*
* This driver provides deterministic authenticated encryption using AES-SIV
* (Synthetic Initialization Vector). It is useful when you need equality
* queries over encrypted values while preserving authenticity guarantees.
*
* @example
* ```ts
* const driver = new AESSIV({
* id: 'app',
* key: 'your-256-bit-key-here'
* })
*
* const encrypted = driver.encrypt('sensitive data')
* const decrypted = driver.decrypt(encrypted)
* ```
*/
export { AESSIV } from '@boringnode/encryption/drivers/aes_siv'
================================================
FILE: modules/encryption/drivers/chacha20_poly1305.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* ChaCha20-Poly1305 encryption driver implementation.
*
* This driver provides authenticated encryption and decryption using the
* ChaCha20-Poly1305 algorithm. ChaCha20 is a modern stream cipher that
* provides excellent performance on systems without AES hardware acceleration.
* Combined with Poly1305 for authentication, it offers both confidentiality
* and authenticity.
*
* @example
* ```ts
* const driver = new ChaCha20Poly1305({
* id: 'app',
* key: 'your-256-bit-key-here'
* })
*
* const encrypted = driver.encrypt('sensitive data')
* const decrypted = driver.decrypt(encrypted)
* ```
*/
export { ChaCha20Poly1305 } from '@boringnode/encryption/drivers/chacha20_poly1305'
================================================
FILE: modules/encryption/drivers/legacy.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { errors } from '@boringnode/encryption'
import { MessageBuilder, type Secret } from '@poppinss/utils'
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
import { BaseDriver, Hmac, base64UrlDecode, base64UrlEncode } from '@boringnode/encryption'
import type {
CypherText,
EncryptOptions,
EncryptionDriverContract,
} from '@boringnode/encryption/types'
import { E_BLIND_INDEX_NOT_SUPPORTED } from '../errors.ts'
/**
* Configuration for the Legacy encryption driver.
*
* The Legacy driver maintains compatibility with the old AdonisJS v6
* encryption format using AES-256-CBC with HMAC SHA-256.
*/
export interface LegacyConfig {
key: string | Secret<string>
}
/**
* Configuration for the Legacy encryption driver factory.
*
* Used when configuring the driver through the defineConfig function.
*/
export interface LegacyDriverConfig {
keys: (string | Secret<string>)[]
}
/**
* Factory function to create a Legacy encryption configuration.
*
* @example
* ```ts
* drivers.legacy({
* keys: [env.get('APP_KEY')]
* })
* ```
*/
export function legacy(config: LegacyDriverConfig) {
return {
driver: (key: string | Secret<string>) => new Legacy({ key }),
keys: config.keys,
}
}
/**
* Legacy encryption driver for AdonisJS.
*
* This driver maintains compatibility with the old AdonisJS v6 encryption
* format. It uses:
* - AES-256-CBC for encryption
* - HMAC SHA-256 for integrity verification
* - MessageBuilder from @poppinss/utils for encoding values
*
* Encrypted format: `[encrypted_base64url].[iv_base64url].[hmac]`
*
* @example
* ```ts
* const driver = new Legacy({ key: 'your-32-character-secret-key!!' })
*
* const encrypted = driver.encrypt('sensitive data')
* const decrypted = driver.decrypt(encrypted)
* ```
*/
export class Legacy extends BaseDriver implements EncryptionDriverContract {
constructor(config: LegacyConfig) {
super(config)
/**
* The key length must be at least 16 characters
*/
if (this.cryptoKey.length < 16) {
throw new errors.E_INSECURE_ENCRYPTER_KEY()
}
}
/**
* Encrypt a given piece of value using the app secret. A wide range of
* data types are supported.
*
* - String
* - Arrays
* - Objects
* - Booleans
* - Numbers
* - Dates
*
* You can optionally define a purpose for which the value was encrypted and
* mentioning a different purpose/no purpose during decrypt will fail.
*/
encrypt(payload: any, options?: EncryptOptions): CypherText
encrypt(payload: any, expiresIn?: string | number, purpose?: string): CypherText
encrypt(
payload: any,
expiresInOrOptions?: string | number | EncryptOptions,
purpose?: string
): CypherText {
let expiresIn: string | number | undefined
let actualPurpose: string | undefined
if (typeof expiresInOrOptions === 'object' && expiresInOrOptions !== null) {
expiresIn = expiresInOrOptions.expiresIn
actualPurpose = expiresInOrOptions.purpose
} else {
expiresIn = expiresInOrOptions
actualPurpose = purpose
}
const iv = randomBytes(16)
/**
* Use the first 32 bytes of the key for AES-256
*/
const encryptionKey = this.cryptoKey.subarray(0, 32)
const cipher = createCipheriv('aes-256-cbc', encryptionKey, iv)
const plainText = new MessageBuilder().build(payload, expiresIn, actualPurpose)
const cipherText = Buffer.concat([cipher.update(plainText), cipher.final()])
const macPayload = `${base64UrlEncode(cipherText)}${this.separator}${base64UrlEncode(iv)}`
const hmac = new Hmac(this.cryptoKey).generate(macPayload)
return this.computeReturns([macPayload, hmac])
}
/**
* Decrypt value and verify it against a purpose
*/
decrypt<T extends any>(value: string, purpose?: string): T | null {
if (typeof value !== 'string') {
return null
}
const [cipherEncoded, ivEncoded, macEncoded] = value.split(this.separator)
if (!cipherEncoded || !ivEncoded || !macEncoded) {
return null
}
const cipherText = base64UrlDecode(cipherEncoded)
if (!cipherText) {
return null
}
const iv = base64UrlDecode(ivEncoded)
if (!iv) {
return null
}
/**
* Verify the HMAC
*/
const isValidHmac = new Hmac(this.cryptoKey).compare(
`${cipherEncoded}${this.separator}${ivEncoded}`,
macEncoded
)
if (!isValidHmac) {
return null
}
try {
/**
* Use the first 32 bytes of the key for AES-256
*/
const encryptionKey = this.cryptoKey.subarray(0, 32)
const decipher = createDecipheriv('aes-256-cbc', encryptionKey, iv)
const plainTextBuffer = Buffer.concat([decipher.update(cipherText), decipher.final()])
return new MessageBuilder().verify<T>(plainTextBuffer, purpose)
} catch {
return null
}
}
/**
* Legacy driver does not support blind indexes.
*/
blindIndex(_payload: any, _purpose: string): string {
throw new E_BLIND_INDEX_NOT_SUPPORTED(['legacy'])
}
/**
* Legacy driver does not support blind indexes.
*/
blindIndexes(_payload: any, _purpose: string): string[] {
throw new E_BLIND_INDEX_NOT_SUPPORTED(['legacy'])
}
}
================================================
FILE: modules/encryption/errors.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { createError } from '../../src/exceptions.ts'
import { errors as boringnodeErrors } from '@boringnode/encryption'
/**
* Raised when attempting to compute blind indexes using the legacy driver.
*/
export const E_BLIND_INDEX_NOT_SUPPORTED = createError<[string]>(
'Blind indexes are not supported by the "%s" encryption driver',
'E_BLIND_INDEX_NOT_SUPPORTED'
)
/**
* Encryption errors exposed by this package.
*/
export const errors = {
...boringnodeErrors,
E_BLIND_INDEX_NOT_SUPPORTED,
}
================================================
FILE: modules/encryption/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Main encryption class for encrypting and decrypting values.
*
* Provides methods to encrypt strings and objects with optional purpose
* binding, decrypt values, and manage encryption keys.
*
* @example
* ```ts
* const encryption = new Encryption({ key: 'secret-key' })
* const encrypted = encryption.encrypt('sensitive data')
* const decrypted = encryption.decrypt(encrypted)
* ```
*/
export { Encryption } from '@boringnode/encryption'
/**
* Manager class for handling multiple encryption instances.
*
* Allows you to configure and manage multiple encryption drivers,
* switch between them, and use different encryption keys for
* different purposes.
*
* @example
* ```ts
* const manager = new EncryptionManager({
* default: 'app',
* list: {
* app: {
* driver: (key) => new AES256GCM({ key }),
* keys: ['app-key']
* }
* }
* })
* const encryptor = manager.use('app')
* ```
*/
export { EncryptionManager } from '@boringnode/encryption'
/**
* HMAC (Hash-based Message Authentication Code) class for creating
* and verifying message authentication codes.
*
* Provides methods to generate cryptographic hashes with a secret key
* and verify them to ensure data integrity and authenticity.
*
* @example
* ```ts
* const hmac = new Hmac('secret-key')
* const signature = hmac.generate('message')
* const isValid = hmac.verify('message', signature)
* ```
*/
export { Hmac } from '@boringnode/encryption'
/**
* Base class for implementing custom encryption drivers.
*
* Extend this class to create custom encryption implementations
* that can be used with the EncryptionManager.
*
* @example
* ```ts
* class CustomDriver extends BaseDriver {
* encrypt(value: string) {
* // Custom encryption logic
* }
* decrypt(payload: string) {
* // Custom decryption logic
* }
* }
* ```
*/
export { BaseDriver } from '@boringnode/encryption'
/**
* Encryption module specific exceptions.
*/
export { errors } from './errors.ts'
/**
* Defines the encryption configuration for the application.
*
* @see {defineConfig} in define_config.ts for detailed documentation
*/
export { defineConfig } from './define_config.ts'
/**
* Collection of built-in encryption driver factory functions.
*
* Includes factories for ChaCha20-Poly1305, AES-256-CBC,
* AES-256-GCM, and AES-SIV encryption algorithms.
*
* @see {drivers} in define_config.ts for detailed documentation
*/
export { drivers } from './define_config.ts'
================================================
FILE: modules/env/editor.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export * from '@adonisjs/env/editor'
================================================
FILE: modules/env/main.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Environment module re-exports all functionality from @adonisjs/env.
* This includes the Env class, validation schemas, and utilities for managing
* environment variables with type safety and validation.
*
* @example
* // Import the Env class and validation
* import { Env } from '@adonisjs/core/env'
*
* const env = await Env.create(new URL('../', import.meta.url), {
* NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
* PORT: Env.schema.number(),
* HOST: Env.schema.string({ format: 'host' })
* })
*
* @example
* // Import environment types and utilities
* import type { EnvParser, EnvEditor } from '@adonisjs/core/env'
*/
export * from '@adonisjs/env'
================================================
FILE: modules/events.ts
================================================
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was
gitextract_zov6uehz/
├── .editorconfig
├── .github/
│ └── workflows/
│ ├── checks.yml
│ ├── labels.yml
│ ├── release.yml
│ ├── stale.yml
│ └── test.yml
├── .gitignore
├── .npmrc
├── .prettierignore
├── LICENSE.md
├── README.md
├── bin/
│ └── test.ts
├── commands/
│ ├── add.ts
│ ├── build.ts
│ ├── configure.ts
│ ├── eject.ts
│ ├── env/
│ │ └── add.ts
│ ├── generate_key.ts
│ ├── inspect_rcfile.ts
│ ├── list/
│ │ └── routes.ts
│ ├── make/
│ │ ├── command.ts
│ │ ├── controller.ts
│ │ ├── event.ts
│ │ ├── exception.ts
│ │ ├── listener.ts
│ │ ├── middleware.ts
│ │ ├── preload.ts
│ │ ├── provider.ts
│ │ ├── service.ts
│ │ ├── test.ts
│ │ ├── transformer.ts
│ │ ├── validator.ts
│ │ └── view.ts
│ ├── repl.ts
│ ├── serve.ts
│ └── test.ts
├── eslint.config.js
├── factories/
│ ├── app.ts
│ ├── bodyparser.ts
│ ├── core/
│ │ ├── ace.ts
│ │ ├── ignitor.ts
│ │ ├── main.ts
│ │ └── test_utils.ts
│ ├── encryption.ts
│ ├── events.ts
│ ├── hash.ts
│ ├── http.ts
│ ├── logger.ts
│ └── stubs.ts
├── funding.json
├── index.ts
├── modules/
│ ├── ace/
│ │ ├── codemods.ts
│ │ ├── commands.ts
│ │ ├── create_kernel.ts
│ │ ├── kernel.ts
│ │ └── main.ts
│ ├── app.ts
│ ├── bodyparser/
│ │ ├── bodyparser_middleware.ts
│ │ └── main.ts
│ ├── config.ts
│ ├── container.ts
│ ├── dumper/
│ │ ├── define_config.ts
│ │ ├── dumper.ts
│ │ ├── errors.ts
│ │ ├── main.ts
│ │ └── plugins/
│ │ └── edge.ts
│ ├── encryption/
│ │ ├── define_config.ts
│ │ ├── drivers/
│ │ │ ├── aes_256_cbc.ts
│ │ │ ├── aes_256_gcm.ts
│ │ │ ├── aes_siv.ts
│ │ │ ├── chacha20_poly1305.ts
│ │ │ └── legacy.ts
│ │ ├── errors.ts
│ │ └── main.ts
│ ├── env/
│ │ ├── editor.ts
│ │ └── main.ts
│ ├── events.ts
│ ├── hash/
│ │ ├── define_config.ts
│ │ ├── drivers/
│ │ │ ├── argon.ts
│ │ │ ├── bcrypt.ts
│ │ │ └── scrypt.ts
│ │ ├── main.ts
│ │ └── phc_formatter.ts
│ ├── health.ts
│ ├── http/
│ │ ├── helpers.ts
│ │ ├── main.ts
│ │ ├── request_validator.ts
│ │ └── url_builder_client.ts
│ ├── logger.ts
│ ├── repl.ts
│ └── transformers/
│ └── main.ts
├── package.json
├── providers/
│ ├── app_provider.ts
│ ├── edge_provider.ts
│ ├── hash_provider.ts
│ ├── repl_provider.ts
│ └── vinejs_provider.ts
├── services/
│ ├── ace.ts
│ ├── app.ts
│ ├── config.ts
│ ├── dumper.ts
│ ├── emitter.ts
│ ├── encryption.ts
│ ├── hash.ts
│ ├── logger.ts
│ ├── repl.ts
│ ├── router.ts
│ ├── server.ts
│ ├── test_utils.ts
│ └── url_builder.ts
├── src/
│ ├── assembler_hooks/
│ │ └── index_entities.ts
│ ├── cli_formatters/
│ │ └── routes_list.ts
│ ├── config_provider.ts
│ ├── debug.ts
│ ├── exceptions.ts
│ ├── helpers/
│ │ ├── assert.ts
│ │ ├── http.ts
│ │ ├── is.ts
│ │ ├── main.ts
│ │ ├── string.ts
│ │ ├── types.ts
│ │ └── verification_token.ts
│ ├── ignitor/
│ │ ├── ace.ts
│ │ ├── http.ts
│ │ ├── main.ts
│ │ └── test.ts
│ ├── test_utils/
│ │ ├── http.ts
│ │ └── main.ts
│ ├── types.ts
│ ├── utils.ts
│ └── vine.ts
├── stubs/
│ ├── main.ts
│ └── make/
│ ├── command/
│ │ └── main.stub
│ ├── controller/
│ │ ├── actions.stub
│ │ ├── api.stub
│ │ ├── main.stub
│ │ └── resource.stub
│ ├── event/
│ │ └── main.stub
│ ├── exception/
│ │ └── main.stub
│ ├── health/
│ │ ├── controller.stub
│ │ └── main.stub
│ ├── listener/
│ │ ├── for_event.stub
│ │ └── main.stub
│ ├── middleware/
│ │ └── main.stub
│ ├── preload/
│ │ └── main.stub
│ ├── provider/
│ │ └── main.stub
│ ├── service/
│ │ └── main.stub
│ ├── test/
│ │ └── main.stub
│ ├── transformer/
│ │ └── main.stub
│ ├── validator/
│ │ ├── main.stub
│ │ └── resource.stub
│ └── view/
│ └── main.stub
├── tests/
│ ├── ace/
│ │ ├── base_command.spec.ts
│ │ ├── codemods.spec.ts
│ │ └── kernel.spec.ts
│ ├── bindings/
│ │ ├── edge.spec.ts
│ │ ├── repl.spec.ts
│ │ └── vinejs.spec.ts
│ ├── cli_formatters/
│ │ └── routes_list.spec.ts
│ ├── commands/
│ │ ├── add.spec.ts
│ │ ├── build.spec.ts
│ │ ├── configure.spec.ts
│ │ ├── eject.spec.ts
│ │ ├── env_add.spec.ts
│ │ ├── generate_key.spec.ts
│ │ ├── inspect_rcfile.spec.ts
│ │ ├── make_command.spec.ts
│ │ ├── make_controller.spec.ts
│ │ ├── make_event.spec.ts
│ │ ├── make_exception.spec.ts
│ │ ├── make_listener.spec.ts
│ │ ├── make_middleware.spec.ts
│ │ ├── make_preload.spec.ts
│ │ ├── make_provider.spec.ts
│ │ ├── make_service.spec.ts
│ │ ├── make_test.spec.ts
│ │ ├── make_transformer.spec.ts
│ │ ├── make_validator.spec.ts
│ │ ├── make_view.spec.ts
│ │ ├── serve.spec.ts
│ │ └── test.spec.ts
│ ├── dumper/
│ │ └── dumper.spec.ts
│ ├── encryption/
│ │ └── legacy.spec.ts
│ ├── hash.spec.ts
│ ├── helpers.spec.ts
│ ├── helpers.ts
│ ├── ignitor/
│ │ ├── ace_process.spec.ts
│ │ ├── http_server_process.spec.ts
│ │ ├── main.spec.ts
│ │ └── test_process.spec.ts
│ ├── index_generator.spec.ts
│ ├── pretty_print_error.spec.ts
│ ├── providers.spec.ts
│ ├── request_validator.spec.ts
│ ├── stubs/
│ │ ├── make_command.spec.ts
│ │ ├── make_controller.spec.ts
│ │ ├── make_event.spec.ts
│ │ ├── make_exception.spec.ts
│ │ ├── make_listener.spec.ts
│ │ ├── make_middleware.spec.ts
│ │ ├── make_prldfile.spec.ts
│ │ ├── make_provider.spec.ts
│ │ ├── make_service.spec.ts
│ │ ├── make_test.spec.ts
│ │ ├── make_validator.spec.ts
│ │ └── make_view.spec.ts
│ ├── test_utils/
│ │ └── http.spec.ts
│ └── verification_token.spec.ts
├── toolkit/
│ ├── commands/
│ │ └── index_commands.ts
│ └── main.ts
├── tsconfig.json
├── typedoc.json
└── types/
├── ace.ts
├── app.ts
├── bodyparser.ts
├── common.ts
├── container.ts
├── encryption.ts
├── events.ts
├── hash.ts
├── health.ts
├── helpers.ts
├── http.ts
├── logger.ts
├── repl.ts
└── transformers.ts
SYMBOL INDEX (410 symbols across 98 files)
FILE: commands/add.ts
class Add (line 28) | class Add extends BaseCommand {
method #resolveNpmPackageName (line 87) | #resolveNpmPackageName(name: string): string {
method #configurePackage (line 101) | async #configurePackage(packageName: string) {
method run (line 119) | async run() {
FILE: commands/build.ts
class Build (line 24) | class Build extends BaseCommand {
method #logMissingDevelopmentDependency (line 70) | #logMissingDevelopmentDependency(dependency: string) {
method run (line 85) | async run() {
FILE: commands/configure.ts
class Configure (line 30) | class Configure extends BaseCommand {
method parsedFlags (line 53) | get parsedFlags() {
method parsedArgs (line 60) | get parsedArgs() {
method #getPackageSource (line 95) | async #getPackageSource(packageName: string) {
method #configureVineJS (line 113) | async #configureVineJS() {
method #configureEdge (line 123) | async #configureEdge() {
method #configureHealthChecks (line 134) | async #configureHealthChecks() {
method createCodemods (line 150) | async createCodemods() {
method run (line 161) | async run() {
FILE: commands/eject.ts
class Eject (line 25) | class Eject extends BaseCommand {
method run (line 57) | async run() {
FILE: commands/env/add.ts
constant ALLOWED_TYPES (line 14) | const ALLOWED_TYPES = ['string', 'boolean', 'number', 'enum'] as const
type AllowedTypes (line 15) | type AllowedTypes = (typeof ALLOWED_TYPES)[number]
class EnvAdd (line 32) | class EnvAdd extends BaseCommand {
method #isTypeFlagValid (line 88) | #isTypeFlagValid() {
method run (line 96) | async run() {
FILE: commands/generate_key.ts
class GenerateKey (line 25) | class GenerateKey extends BaseCommand {
method run (line 52) | async run() {
FILE: commands/inspect_rcfile.ts
class InspectRCFile (line 22) | class InspectRCFile extends BaseCommand {
method run (line 39) | async run() {
FILE: commands/list/routes.ts
class ListRoutes (line 29) | class ListRoutes extends BaseCommand {
method run (line 103) | async run() {
FILE: commands/make/command.ts
class MakeCommand (line 27) | class MakeCommand extends BaseCommand {
method run (line 60) | async run() {
FILE: commands/make/controller.ts
class MakeController (line 27) | class MakeController extends BaseCommand {
method prepare (line 100) | async prepare() {
method run (line 138) | async run() {
FILE: commands/make/event.ts
class MakeEvent (line 26) | class MakeEvent extends BaseCommand {
method run (line 68) | async run() {
FILE: commands/make/exception.ts
class MakeException (line 26) | class MakeException extends BaseCommand {
method run (line 68) | async run() {
FILE: commands/make/listener.ts
class MakeListener (line 26) | class MakeListener extends BaseCommand {
method prepare (line 77) | prepare() {
method run (line 88) | async run() {
FILE: commands/make/middleware.ts
class MakeMiddleware (line 30) | class MakeMiddleware extends BaseCommand {
method run (line 72) | async run() {
FILE: commands/make/preload.ts
constant ALLOWED_ENVIRONMENTS (line 17) | const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'] satisfie...
type AllowedAppEnvironments (line 18) | type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS
class MakePreload (line 34) | class MakePreload extends BaseCommand {
method #isEnvironmentsFlagValid (line 88) | #isEnvironmentsFlagValid() {
method run (line 100) | async run() {
FILE: commands/make/provider.ts
constant ALLOWED_ENVIRONMENTS (line 17) | const ALLOWED_ENVIRONMENTS = ['web', 'console', 'test', 'repl'] satisfie...
type AllowedAppEnvironments (line 18) | type AllowedAppEnvironments = typeof ALLOWED_ENVIRONMENTS
class MakeProvider (line 33) | class MakeProvider extends BaseCommand {
method #isEnvironmentsFlagValid (line 87) | #isEnvironmentsFlagValid() {
method run (line 98) | async run() {
FILE: commands/make/service.ts
class MakeService (line 24) | class MakeService extends BaseCommand {
method run (line 60) | async run() {
FILE: commands/make/test.ts
class MakeTest (line 25) | class MakeTest extends BaseCommand {
method #getSuite (line 68) | async #getSuite(): Promise<string> {
method #getSuiteDirectory (line 105) | async #getSuiteDirectory(directories: string[]): Promise<string> {
method #findSuite (line 123) | #findSuite(suiteName: string) {
method run (line 134) | async run() {
FILE: commands/make/transformer.ts
class MakeTransformer (line 27) | class MakeTransformer extends BaseCommand {
method run (line 69) | async run() {
FILE: commands/make/validator.ts
class MakeValidator (line 27) | class MakeValidator extends BaseCommand {
method prepare (line 77) | async prepare() {
method run (line 90) | async run() {
FILE: commands/make/view.ts
class MakeView (line 26) | class MakeView extends BaseCommand {
method run (line 59) | async run() {
FILE: commands/repl.ts
class ReplCommand (line 24) | class ReplCommand extends BaseCommand {
method run (line 50) | async run() {
FILE: commands/serve.ts
class Serve (line 29) | class Serve extends BaseCommand {
method #logMissingDevelopmentDependency (line 109) | #logMissingDevelopmentDependency(dependency: string) {
method run (line 124) | async run() {
FILE: commands/test.ts
class Test (line 32) | class Test extends BaseCommand {
method #logMissingDevelopmentDependency (line 143) | #logMissingDevelopmentDependency(dependency: string) {
method #getPassthroughFlags (line 161) | #getPassthroughFlags(): string[] {
method run (line 190) | async run() {
FILE: factories/core/ace.ts
class AceFactory (line 35) | class AceFactory {
method make (line 49) | async make(ignitorOrAppRoot: URL | Ignitor, options?: IgnitorOptions):...
FILE: factories/core/ignitor.ts
type FactoryParameters (line 23) | type FactoryParameters = {
class IgnitorFactory (line 47) | class IgnitorFactory {
method preload (line 70) | preload(action: (app: ApplicationService) => void | Promise<void>): th...
method #mergeCoreProviders (line 78) | #mergeCoreProviders(providers?: ProviderNode['file'][]): ProviderNode[...
method merge (line 108) | merge(params: Partial<FactoryParameters>): this {
method withCoreProviders (line 134) | withCoreProviders(): this {
method withCoreConfig (line 151) | withCoreConfig(): this {
method create (line 200) | create(appRoot: URL, options?: IgnitorOptions): Ignitor {
FILE: factories/core/test_utils.ts
class TestUtilsFactory (line 35) | class TestUtilsFactory {
method create (line 49) | create(ignitorOrAppRoot: URL | Ignitor, options?: IgnitorOptions): Tes...
FILE: factories/stubs.ts
type FactoryParameters (line 15) | type FactoryParameters = {
class StubsFactory (line 40) | class StubsFactory {
method #getApp (line 46) | #getApp() {
method merge (line 63) | merge(params: Partial<FactoryParameters>): this {
method prepare (line 93) | async prepare(stubPath: string, data: Record<string, any>) {
FILE: index.ts
function prettyPrintError (line 41) | async function prettyPrintError(error: any) {
FILE: modules/ace/codemods.ts
class Codemods (line 52) | class Codemods extends EventEmitter {
method constructor (line 79) | constructor(app: Application<any>, cliLogger: UIPrimitives['logger']) {
method #getCodeTransformer (line 89) | async #getCodeTransformer() {
method #getInstallationCommands (line 106) | #getInstallationCommands(packages: string[], packageManager: string, i...
method defineEnvVariables (line 144) | async defineEnvVariables<T extends Record<string, number | string | bo...
method getTsMorphProject (line 173) | async getTsMorphProject(): Promise<CodeTransformer['project'] | undefi...
method defineEnvValidations (line 200) | async defineEnvValidations(validations: EnvValidationNode) {
method registerMiddleware (line 236) | async registerMiddleware(stack: 'server' | 'router' | 'named', middlew...
method registerPolicies (line 272) | async registerPolicies(policies: BouncerPolicyNode[]) {
method updateRcFile (line 305) | async updateRcFile(...params: Parameters<CodeTransformer['updateRcFile...
method registerVitePlugin (line 339) | async registerVitePlugin(...params: Parameters<CodeTransformer['addVit...
method registerJapaPlugin (line 372) | async registerJapaPlugin(...params: Parameters<CodeTransformer['addJap...
method addValidator (line 406) | async addValidator(...params: Parameters<CodeTransformer['addValidator...
method addLimiter (line 440) | async addLimiter(...params: Parameters<CodeTransformer['addLimiter']>) {
method addModelMixins (line 476) | async addModelMixins(...params: Parameters<CodeTransformer['addModelMi...
method addControllerMethod (line 514) | async addControllerMethod(...params: Parameters<CodeTransformer['addCo...
method makeUsingStub (line 553) | async makeUsingStub(
method installPackages (line 618) | async installPackages(
method listPackagesToInstall (line 705) | async listPackagesToInstall(packages: { name: string; isDevDependency:...
FILE: modules/ace/commands.ts
class BaseCommand (line 34) | class BaseCommand extends AceBaseCommand {
method staysAlive (line 37) | get staysAlive() {
method startApp (line 41) | get startApp() {
method constructor (line 45) | constructor(
method createCodemods (line 68) | async createCodemods() {
method exec (line 105) | async exec() {
method terminate (line 156) | async terminate() {
class ListCommand (line 167) | class ListCommand extends AceListCommand implements BaseCommand {
method staysAlive (line 170) | get staysAlive() {
method startApp (line 174) | get startApp() {
method constructor (line 178) | constructor(
method run (line 192) | async run() {
method createCodemods (line 203) | async createCodemods() {
method terminate (line 214) | async terminate() {
FILE: modules/ace/create_kernel.ts
function createAceKernel (line 34) | function createAceKernel(app: ApplicationService, commandName?: string) {
FILE: modules/ace/kernel.ts
class Kernel (line 27) | class Kernel extends AceKernel<typeof BaseCommand> {
method constructor (line 33) | constructor(public app: ApplicationService) {
FILE: modules/dumper/define_config.ts
function defineConfig (line 38) | function defineConfig(
FILE: modules/dumper/dumper.ts
constant DUMP_TITLE_STYLES (line 21) | const DUMP_TITLE_STYLES = `
constant IDE (line 49) | const IDE = process.env.ADONIS_IDE ?? process.env.EDITOR ?? ''
class Dumper (line 76) | class Dumper {
method constructor (line 110) | constructor(app: Application<any>) {
method #getEditorLink (line 123) | #getEditorLink(source?: {
method configureHtmlOutput (line 152) | configureHtmlOutput(config: HTMLDumpConfig): this {
method configureAnsiOutput (line 171) | configureAnsiOutput(config: ConsoleDumpConfig): this {
method getHeadElements (line 188) | getHeadElements(cspNonce?: string): string {
method dumpToHtml (line 217) | dumpToHtml(
method dumpToAnsi (line 257) | dumpToAnsi(
method dd (line 314) | dd(value: unknown, traceSourceIndex: number = 1) {
FILE: modules/dumper/errors.ts
class DumpDieException (line 32) | class DumpDieException extends Exception {
method constructor (line 43) | constructor(value: unknown, dumper: Dumper) {
method #getErrorSource (line 52) | #getErrorSource(): { location: string; line: number } | undefined {
method setTraceSourceIndex (line 77) | setTraceSourceIndex(index: number) {
method report (line 86) | report() {}
method handle (line 96) | async handle(error: DumpDieException, ctx: HttpContext) {
method render (line 129) | async render(error: DumpDieException, kernel: Kernel) {
method [inspect.custom] (line 137) | [inspect.custom]() {
constant E_DUMP_DIE_EXCEPTION (line 143) | const E_DUMP_DIE_EXCEPTION = DumpDieException
FILE: modules/dumper/plugins/edge.ts
function pluginEdgeDumper (line 17) | function pluginEdgeDumper(dumper: Dumper) {
FILE: modules/encryption/define_config.ts
type ResolvedConfig (line 34) | type ResolvedConfig<
function defineConfig (line 86) | function defineConfig<
FILE: modules/encryption/drivers/legacy.ts
type LegacyConfig (line 27) | interface LegacyConfig {
type LegacyDriverConfig (line 36) | interface LegacyDriverConfig {
function legacy (line 50) | function legacy(config: LegacyDriverConfig) {
class Legacy (line 76) | class Legacy extends BaseDriver implements EncryptionDriverContract {
method constructor (line 77) | constructor(config: LegacyConfig) {
method encrypt (line 104) | encrypt(
method decrypt (line 140) | decrypt<T extends any>(value: string, purpose?: string): T | null {
method blindIndex (line 191) | blindIndex(_payload: any, _purpose: string): string {
method blindIndexes (line 198) | blindIndexes(_payload: any, _purpose: string): string[] {
FILE: modules/encryption/errors.ts
constant E_BLIND_INDEX_NOT_SUPPORTED (line 16) | const E_BLIND_INDEX_NOT_SUPPORTED = createError<[string]>(
FILE: modules/hash/define_config.ts
type ResolvedConfig (line 29) | type ResolvedConfig<
function defineConfig (line 65) | function defineConfig<
FILE: modules/http/request_validator.ts
class RequestValidator (line 34) | class RequestValidator {
method constructor (line 37) | constructor(ctx: HttpContext) {
method #requestData (line 59) | #requestData() {
method #processValidatorOptions (line 69) | #processValidatorOptions<MetaData extends undefined | Record<string, a...
method validateUsing (line 115) | validateUsing<Schema extends SchemaTypes, MetaData extends undefined |...
method tryValidateUsing (line 134) | async tryValidateUsing<
FILE: modules/logger.ts
function syncDestination (line 43) | async function syncDestination(
FILE: providers/app_provider.ts
class AppServiceProvider (line 46) | class AppServiceProvider {
method constructor (line 52) | constructor(protected app: ApplicationService) {}
method registerTestUtils (line 64) | protected registerTestUtils() {
method registerAce (line 81) | protected registerAce() {
method registerApp (line 98) | protected registerApp() {
method registerLogger (line 113) | protected registerLogger() {
method registerLoggerManager (line 130) | protected registerLoggerManager() {
method registerConfig (line 148) | protected registerConfig() {
method registerEmitter (line 163) | protected registerEmitter() {
method registerEncryption (line 181) | protected registerEncryption() {
method registerServer (line 216) | protected registerServer() {
method registerRouter (line 238) | protected registerRouter() {
method registerBodyParserMiddleware (line 257) | protected registerBodyParserMiddleware() {
method registerDumper (line 275) | protected registerDumper() {
method emitRoutes (line 307) | protected async emitRoutes(router: Router) {
method register (line 353) | register() {
method boot (line 378) | async boot() {
method ready (line 392) | async ready() {
FILE: providers/edge_provider.ts
type HttpContext (line 18) | interface HttpContext {
type BriskRoute (line 26) | interface BriskRoute {
class EdgeServiceProvider (line 50) | class EdgeServiceProvider {
method constructor (line 58) | constructor(protected app: ApplicationService) {
method boot (line 76) | async boot() {
FILE: providers/hash_provider.ts
class HashServiceProvider (line 29) | class HashServiceProvider {
method constructor (line 35) | constructor(protected app: ApplicationService) {}
method registerHash (line 48) | protected registerHash() {
method registerHashManager (line 66) | protected registerHashManager() {
method register (line 95) | register() {
FILE: providers/repl_provider.ts
function resolveBindingForRepl (line 32) | async function resolveBindingForRepl(
class ReplServiceProvider (line 60) | class ReplServiceProvider {
method constructor (line 66) | constructor(protected app: ApplicationService) {}
method register (line 79) | register() {
method boot (line 102) | async boot() {
FILE: providers/vinejs_provider.ts
type Vine (line 19) | interface Vine {
type HttpRequest (line 28) | interface HttpRequest extends RequestValidator {}
class VineJSServiceProvider (line 45) | class VineJSServiceProvider {
method constructor (line 53) | constructor(protected app: ApplicationService) {
method boot (line 67) | boot() {
FILE: services/app.ts
function setApp (line 22) | function setApp(appService: ApplicationService) {
FILE: src/assembler_hooks/index_entities.ts
function indexEntities (line 53) | function indexEntities(entities: IndexEntitiesConfig = {}) {
FILE: src/cli_formatters/routes_list.ts
type SerializedRoute (line 20) | type SerializedRoute = {
class RoutesListFormatter (line 45) | class RoutesListFormatter {
method constructor (line 86) | constructor(
method #isAllowedByFilters (line 112) | #isAllowedByFilters(route: SerializedRoute) {
method #serializeRoute (line 187) | async #serializeRoute(route: RouteJSON): Promise<SerializedRoute> {
method #formatRouteMethod (line 213) | #formatRouteMethod(method: string) {
method #formatRoutePattern (line 222) | #formatRoutePattern(route: SerializedRoute) {
method #formatControllerName (line 252) | #formatControllerName(route: SerializedRoute) {
method #formatAction (line 263) | #formatAction(route: SerializedRoute) {
method #formatMiddleware (line 282) | #formatMiddleware(route: SerializedRoute, mode: 'normal' | 'compact' =...
method #formatDomainHeadline (line 302) | #formatDomainHeadline(domain: string) {
method #justifyListTables (line 315) | #justifyListTables(tables: { heading: string; rows: [string, string, s...
method #formatMiddlewareAsString (line 383) | #formatMiddlewareAsString(middleware: MiddlewareHandlerInfo): string |...
method formatAsJSONL (line 396) | async formatAsJSONL(): Promise<string[]> {
method formatAsJSON (line 459) | async formatAsJSON() {
method formatAsAnsiList (line 483) | async formatAsAnsiList() {
method formatAsAnsiTable (line 532) | async formatAsAnsiTable() {
FILE: src/config_provider.ts
method create (line 46) | create<T>(resolver: ConfigProvider<T>['resolver']): ConfigProvider<T> {
method resolve (line 69) | async resolve<T>(app: ApplicationService, provider: unknown): Promise<T ...
FILE: src/helpers/string.ts
method create (line 144) | create(value: string | StringBuilder): StringBuilder {
method prettyHrTime (line 154) | prettyHrTime(time, options) {
method isEmpty (line 163) | isEmpty(value: string): boolean {
method escapeHTML (line 174) | escapeHTML(value: string, options?: { encodeSymbols?: boolean }): string {
method encodeSymbols (line 188) | encodeSymbols(value: string, options?: EncodeOptions): string {
FILE: src/helpers/types.ts
method isFloat (line 128) | isFloat(value: number): value is number {
method isDecimal (line 146) | isDecimal(value: string | number, options?: { decimalPlaces?: string }):...
FILE: src/helpers/verification_token.ts
method decode (line 41) | static decode(value: string): null | { identifier: string; secret: Secre...
method createTransientToken (line 81) | static createTransientToken(
method seed (line 101) | static seed(size: number) {
method computeValue (line 145) | protected computeValue(secret: Secret<string>) {
method isExpired (line 156) | isExpired() {
method verify (line 165) | verify(secret: Secret<string>): boolean {
FILE: src/ignitor/ace.ts
class AceProcess (line 28) | class AceProcess {
method constructor (line 45) | constructor(ignitor: Ignitor) {
method configure (line 55) | configure(callback: (app: ApplicationService) => Promise<void> | void)...
method handle (line 66) | async handle(argv: string[]) {
FILE: src/ignitor/http.ts
class HttpServerProcess (line 32) | class HttpServerProcess {
method constructor (line 43) | constructor(ignitor: Ignitor) {
method #close (line 52) | #close(nodeHttpServer: NodeHttpsServer | NodeHttpServer): Promise<void> {
method #monitorAppAndServer (line 67) | #monitorAppAndServer(
method #listen (line 97) | #listen(
method #notifyServerHasStarted (line 125) | #notifyServerHasStarted(
method start (line 152) | async start(
FILE: src/ignitor/main.ts
class Ignitor (line 36) | class Ignitor {
method constructor (line 68) | constructor(appRoot: URL, options: IgnitorOptions = {}) {
method #runTapCallbacks (line 76) | #runTapCallbacks(app: ApplicationService) {
method getApp (line 85) | getApp() {
method createApp (line 94) | createApp(environment: AppEnvironments) {
method tap (line 108) | tap(callback: (app: ApplicationService) => void): this {
method httpServer (line 116) | httpServer() {
method ace (line 123) | ace() {
method testRunner (line 130) | testRunner() {
method terminate (line 138) | async terminate() {
FILE: src/ignitor/test.ts
class TestRunnerProcess (line 30) | class TestRunnerProcess {
method constructor (line 47) | constructor(ignitor: Ignitor) {
method configure (line 57) | configure(callback: (app: ApplicationService) => Promise<void> | void)...
method run (line 67) | async run(callback: (app: ApplicationService) => Promise<void> | void) {
FILE: src/test_utils/http.ts
class HttpServerUtils (line 33) | class HttpServerUtils {
method constructor (line 44) | constructor(utils: TestUtils) {
method #listen (line 53) | #listen(
method start (line 78) | async start(
FILE: src/test_utils/main.ts
class TestUtils (line 31) | class TestUtils extends Macroable {
method isBooted (line 40) | get isBooted() {
method constructor (line 54) | constructor(public app: ApplicationService) {
method boot (line 62) | async boot() {
method httpServer (line 73) | httpServer() {
method createHttpContext (line 82) | async createHttpContext(
FILE: src/types.ts
type ConfigProvider (line 52) | type ConfigProvider<T> = {
type IgnitorOptions (line 67) | type IgnitorOptions = {
type EventsList (line 86) | interface EventsList extends HttpServerEvents {
type LoggersList (line 107) | interface LoggersList {}
type InferLoggers (line 114) | type InferLoggers<T extends LoggerManagerConfig<any>> = T['loggers']
type HashersList (line 130) | interface HashersList {}
type InferHashers (line 137) | type InferHashers<T extends ConfigProvider<{ list: Record<string, Manage...
type EncryptorsList (line 154) | interface EncryptorsList {}
type InferEncryptors (line 161) | type InferEncryptors<
type ApplicationService (line 182) | interface ApplicationService extends Application<
type LoggerService (line 190) | interface LoggerService extends LoggerManager<
type EmitterService (line 198) | interface EmitterService extends Emitter<EventsList> {}
type EncryptionService (line 205) | interface EncryptionService extends EncryptionManager<
type HttpServerService (line 214) | interface HttpServerService extends Server {}
type HttpRouterService (line 221) | interface HttpRouterService extends Router {}
type UrlBuilderUrlFor (line 228) | interface UrlBuilderUrlFor extends UrlFor<
type UrlBuilderSignedUrlFor (line 238) | interface UrlBuilderSignedUrlFor extends UrlFor<
type HashService (line 248) | interface HashService extends HashManager<
type ContainerBindings (line 257) | interface ContainerBindings {
type IndexEntitiesConfig (line 310) | type IndexEntitiesConfig = {
FILE: src/utils.ts
function importAssembler (line 29) | async function importAssembler(
function importTypeScript (line 52) | async function importTypeScript(
function outputTransformerDataObjects (line 84) | async function outputTransformerDataObjects(
FILE: src/vine.ts
constant MULTIPART_FILE (line 14) | const MULTIPART_FILE: typeof symbols.SUBTYPE = symbols.SUBTYPE ?? Symbol...
type FileRuleValidationOptions (line 19) | type FileRuleValidationOptions =
function isBodyParserFile (line 29) | function isBodyParserFile(file: unknown): file is MultipartFile {
class VineMultipartFile (line 101) | class VineMultipartFile extends BaseLiteralType<
method constructor (line 123) | constructor(
method clone (line 137) | clone() {
FILE: tests/ace/base_command.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
class MakeController (line 26) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 50) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 84) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 106) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 134) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 162) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 190) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 218) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 250) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
class MakeController (line 269) | class MakeController extends BaseCommand {
method prepare (line 54) | async prepare() {
method interact (line 58) | async interact() {
method run (line 62) | async run() {
method completed (line 66) | async completed() {
method run (line 88) | async run() {
method prepare (line 108) | async prepare() {
method interact (line 136) | async interact() {
method run (line 164) | async run() {
method run (line 192) | async run() {
method completed (line 196) | async completed() {
method run (line 220) | async run() {
method completed (line 224) | async completed() {
method completed (line 252) | async completed() {
FILE: tests/ace/kernel.spec.ts
constant BASE_URL (line 16) | const BASE_URL = new URL('./tmp/', import.meta.url)
method getMetaData (line 110) | async getMetaData() {
FILE: tests/bindings/edge.spec.ts
constant BASE_URL (line 18) | const BASE_URL = new URL('./tmp/', import.meta.url)
FILE: tests/bindings/repl.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
method importer (line 33) | importer(filePath: string) {
method displayPrompt (line 49) | displayPrompt() {}
FILE: tests/bindings/vinejs.spec.ts
constant BASE_URL (line 16) | const BASE_URL = new URL('./tmp/', import.meta.url)
method importer (line 32) | importer(filePath: string) {
FILE: tests/cli_formatters/routes_list.spec.ts
function registerRoutes (line 19) | async function registerRoutes(app: ApplicationService) {
FILE: tests/commands/add.spec.ts
constant VERBOSE (line 18) | const VERBOSE = !!process.env.CI
FILE: tests/commands/configure.spec.ts
constant BASE_URL (line 16) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 17) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/encryption/legacy.spec.ts
constant SECRET_KEY (line 17) | const SECRET_KEY = 'averylongsecretkeythatshouldbe32'
FILE: tests/hash.spec.ts
constant BASE_URL (line 20) | const BASE_URL = new URL('./tmp/', import.meta.url)
FILE: tests/helpers.ts
function setupProject (line 44) | async function setupProject(
function setupPackage (line 71) | async function setupPackage(fs: FileSystem, configureContent?: string) {
function setupNamedPackage (line 78) | async function setupNamedPackage(
FILE: tests/ignitor/ace_process.spec.ts
constant BASE_URL (line 16) | const BASE_URL = new URL('./tmp/', import.meta.url)
class Greet (line 40) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 76) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 116) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 149) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 182) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 228) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class Greet (line 279) | class Greet extends BaseCommand {
method run (line 42) | async run() {
method run (line 82) | async run() {
method run (line 118) | async run() {
method run (line 151) | async run() {
method run (line 188) | async run() {
method run (line 234) | async run() {
method run (line 285) | async run() {
class CustomRepl (line 317) | class CustomRepl extends BaseCommand {
method run (line 323) | async run() {}
FILE: tests/ignitor/http_server_process.spec.ts
constant BASE_URL (line 19) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 20) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/ignitor/main.spec.ts
constant BASE_URL (line 13) | const BASE_URL = new URL('./tmp/', import.meta.url)
FILE: tests/ignitor/test_process.spec.ts
constant BASE_URL (line 13) | const BASE_URL = new URL('./tmp/', import.meta.url)
FILE: tests/providers.spec.ts
constant BASE_URL (line 28) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 29) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/request_validator.spec.ts
constant BASE_URL (line 18) | const BASE_URL = new URL('./tmp/', import.meta.url)
class MyErrorReporter (line 292) | class MyErrorReporter extends SimpleErrorReporter {
method report (line 293) | report(
method report (line 451) | report(
class MyErrorReporter (line 450) | class MyErrorReporter extends SimpleErrorReporter {
method report (line 293) | report(
method report (line 451) | report(
FILE: tests/stubs/make_command.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_controller.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_event.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_exception.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_listener.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_middleware.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_prldfile.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_provider.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_service.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_test.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_validator.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/stubs/make_view.spec.ts
constant BASE_URL (line 17) | const BASE_URL = new URL('./tmp/', import.meta.url)
constant BASE_PATH (line 18) | const BASE_PATH = fileURLToPath(BASE_URL)
FILE: tests/test_utils/http.spec.ts
constant BASE_URL (line 19) | const BASE_URL = new URL('./tmp/', import.meta.url)
FILE: tests/verification_token.spec.ts
function freezeTime (line 17) | function freezeTime() {
class EmailVerificationToken (line 33) | class EmailVerificationToken extends VerificationToken {
method constructor (line 34) | constructor(props: {
FILE: toolkit/commands/index_commands.ts
class IndexCommand (line 17) | class IndexCommand extends BaseCommand {
method run (line 24) | async run(): Promise<any> {
FILE: types/ace.ts
type CommandOptions (line 11) | type CommandOptions = BaseCommandOptions & {
FILE: types/http.ts
type RequestValidationOptions (line 17) | type RequestValidationOptions<MetaData extends undefined | Record<string...
Condensed preview — 226 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (703K chars).
[
{
"path": ".editorconfig",
"chars": 340,
"preview": "# http://editorconfig.org\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_white"
},
{
"path": ".github/workflows/checks.yml",
"chars": 311,
"preview": "name: checks\non:\n - push\n - pull_request\n - workflow_call\njobs:\n test:\n uses: adonisjs/core/.github/workflows/tes"
},
{
"path": ".github/workflows/labels.yml",
"chars": 383,
"preview": "name: Sync labels\non:\n workflow_dispatch:\npermissions:\n issues: write\njobs:\n labels:\n runs-on: ubuntu-latest\n s"
},
{
"path": ".github/workflows/release.yml",
"chars": 914,
"preview": "name: release\non: workflow_dispatch\npermissions:\n contents: write\n id-token: write\njobs:\n checks:\n uses: ./.github"
},
{
"path": ".github/workflows/stale.yml",
"chars": 1022,
"preview": "name: 'Close stale issues and PRs'\non:\n schedule:\n - cron: '30 0 * * *'\n\njobs:\n stale:\n runs-on: ubuntu-latest\n "
},
{
"path": ".github/workflows/test.yml",
"chars": 1507,
"preview": "on:\n workflow_call:\n inputs:\n disable-windows:\n description: Disable running tests on Windows\n ty"
},
{
"path": ".gitignore",
"chars": 181,
"preview": "node_modules\ncoverage\n.DS_STORE\n.nyc_output\n.idea\n.vscode/\n*.sublime-project\n*.sublime-workspace\n*.log\nbuild\ndist\nyarn.l"
},
{
"path": ".npmrc",
"chars": 19,
"preview": "package-lock=false\n"
},
{
"path": ".prettierignore",
"chars": 20,
"preview": "build\ndocs\ncoverage\n"
},
{
"path": "LICENSE.md",
"chars": 1087,
"preview": "# The MIT License\n\nCopyright 2022 Harminder Virk, contributors\n\nPermission is hereby granted, free of charge, to any per"
},
{
"path": "README.md",
"chars": 2727,
"preview": "# @adonisjs/core\n\n**Featured sponsors**\n\n<table>\n\n<tr>\n<td>\n\n<a href=\"https://route4me.com/?utm_source=adonisjs.com\">\n "
},
{
"path": "bin/test.ts",
"chars": 1119,
"preview": "import { assert } from '@japa/assert'\nimport { snapshot } from '@japa/snapshot'\nimport { fileSystem } from '@japa/file-s"
},
{
"path": "commands/add.ts",
"chars": 4655,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/build.ts",
"chars": 3344,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/configure.ts",
"chars": 5855,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/eject.ts",
"chars": 1838,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/env/add.ts",
"chars": 4524,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/generate_key.ts",
"chars": 1769,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/inspect_rcfile.ts",
"chars": 1736,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/list/routes.ts",
"chars": 4415,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/command.ts",
"chars": 1932,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/controller.ts",
"chars": 3876,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/event.ts",
"chars": 2069,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/exception.ts",
"chars": 2163,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/listener.ts",
"chars": 3369,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/middleware.ts",
"chars": 3600,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/preload.ts",
"chars": 4442,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/provider.ts",
"chars": 4394,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/service.ts",
"chars": 1742,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/test.ts",
"chars": 4473,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/transformer.ts",
"chars": 2293,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/validator.ts",
"chars": 2742,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/make/view.ts",
"chars": 1844,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/repl.ts",
"chars": 1518,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/serve.ts",
"chars": 4645,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "commands/test.ts",
"chars": 7080,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "eslint.config.js",
"chars": 107,
"preview": "import { configPkg } from '@adonisjs/eslint-config'\nexport default configPkg({\n ignores: ['coverage'],\n})\n"
},
{
"path": "factories/app.ts",
"chars": 223,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/bodyparser.ts",
"chars": 222,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/core/ace.ts",
"chars": 1987,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/core/ignitor.ts",
"chars": 6272,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/core/main.ts",
"chars": 310,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/core/test_utils.ts",
"chars": 1853,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/encryption.ts",
"chars": 224,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/events.ts",
"chars": 218,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/hash.ts",
"chars": 216,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/http.ts",
"chars": 223,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/logger.ts",
"chars": 218,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "factories/stubs.ts",
"chars": 2902,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "funding.json",
"chars": 8772,
"preview": "{\n \"version\": \"v1.0.0\",\n \"entity\": {\n \"type\": \"individual\",\n \"role\": \"owner\",\n \"name\": \"Harminder Virk\",\n "
},
{
"path": "index.ts",
"chars": 1458,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/ace/codemods.ts",
"chars": 21750,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/ace/commands.ts",
"chars": 5942,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/ace/create_kernel.ts",
"chars": 2894,
"preview": "/*\n * @adonisjs/ace\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * "
},
{
"path": "modules/ace/kernel.ts",
"chars": 1215,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/ace/main.ts",
"chars": 1310,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/app.ts",
"chars": 795,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/bodyparser/bodyparser_middleware.ts",
"chars": 393,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/bodyparser/main.ts",
"chars": 212,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/config.ts",
"chars": 771,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/container.ts",
"chars": 206,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/dumper/define_config.ts",
"chars": 1126,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/dumper/dumper.ts",
"chars": 8702,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/dumper/errors.ts",
"chars": 3998,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/dumper/main.ts",
"chars": 997,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/dumper/plugins/edge.ts",
"chars": 2623,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/define_config.ts",
"chars": 8543,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/drivers/aes_256_cbc.ts",
"chars": 829,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/drivers/aes_256_gcm.ts",
"chars": 901,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/drivers/aes_siv.ts",
"chars": 743,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/drivers/chacha20_poly1305.ts",
"chars": 881,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/drivers/legacy.ts",
"chars": 5438,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/errors.ts",
"chars": 684,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/encryption/main.ts",
"chars": 2686,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/env/editor.ts",
"chars": 212,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/env/main.ts",
"chars": 885,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/events.ts",
"chars": 208,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/define_config.ts",
"chars": 4856,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/drivers/argon.ts",
"chars": 220,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/drivers/bcrypt.ts",
"chars": 592,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/drivers/scrypt.ts",
"chars": 221,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/main.ts",
"chars": 955,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/hash/phc_formatter.ts",
"chars": 220,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/health.ts",
"chars": 208,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/http/helpers.ts",
"chars": 221,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/http/main.ts",
"chars": 411,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/http/request_validator.ts",
"chars": 4671,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/http/url_builder_client.ts",
"chars": 232,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/logger.ts",
"chars": 1495,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/repl.ts",
"chars": 206,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "modules/transformers/main.ts",
"chars": 219,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "package.json",
"chars": 9175,
"preview": "{\n \"name\": \"@adonisjs/core\",\n \"description\": \"Core of AdonisJS\",\n \"version\": \"7.1.1\",\n \"engines\": {\n \"node\": \">=2"
},
{
"path": "providers/app_provider.ts",
"chars": 12435,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "providers/edge_provider.ts",
"chars": 6802,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "providers/hash_provider.ts",
"chars": 2898,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "providers/repl_provider.ts",
"chars": 6451,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "providers/vinejs_provider.ts",
"chars": 2471,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/ace.ts",
"chars": 560,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/app.ts",
"chars": 601,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/config.ts",
"chars": 459,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/dumper.ts",
"chars": 695,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/emitter.ts",
"chars": 482,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/encryption.ts",
"chars": 503,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/hash.ts",
"chars": 463,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/logger.ts",
"chars": 475,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/repl.ts",
"chars": 450,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/router.ts",
"chars": 483,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/server.ts",
"chars": 482,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/test_utils.ts",
"chars": 603,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "services/url_builder.ts",
"chars": 639,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/assembler_hooks/index_entities.ts",
"chars": 6266,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/cli_formatters/routes_list.ts",
"chars": 16898,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/config_provider.ts",
"chars": 2344,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/debug.ts",
"chars": 716,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/exceptions.ts",
"chars": 1421,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/assert.ts",
"chars": 1611,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/http.ts",
"chars": 933,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/is.ts",
"chars": 838,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/main.ts",
"chars": 1722,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/string.ts",
"chars": 6044,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/types.ts",
"chars": 3526,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/helpers/verification_token.ts",
"chars": 4479,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/ignitor/ace.ts",
"chars": 3303,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/ignitor/http.ts",
"chars": 5855,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/ignitor/main.ts",
"chars": 3365,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/ignitor/test.ts",
"chars": 1923,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/test_utils/http.ts",
"chars": 2772,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/test_utils/main.ts",
"chars": 2498,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/types.ts",
"chars": 11435,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/utils.ts",
"chars": 4680,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "src/vine.ts",
"chars": 4002,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "stubs/main.ts",
"chars": 220,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "stubs/make/command/main.stub",
"chars": 655,
"preview": "{{#var commandName = generators.commandName(entity.name)}}\n{{#var commandTerminalName = generators.commandTerminalName(e"
},
{
"path": "stubs/make/controller/actions.stub",
"chars": 431,
"preview": "{{#var controllerName = generators.controllerName(entity.name, singular)}}\n{{#var controllerFileName = generators.contro"
},
{
"path": "stubs/make/controller/api.stub",
"chars": 805,
"preview": "{{#var controllerName = generators.controllerName(entity.name, singular)}}\n{{#var controllerFileName = generators.contro"
},
{
"path": "stubs/make/controller/main.stub",
"chars": 353,
"preview": "{{#var controllerName = generators.controllerName(entity.name, singular)}}\n{{#var controllerFileName = generators.contro"
},
{
"path": "stubs/make/controller/resource.stub",
"chars": 976,
"preview": "{{#var controllerName = generators.controllerName(entity.name, singular)}}\n{{#var controllerFileName = generators.contro"
},
{
"path": "stubs/make/event/main.stub",
"chars": 399,
"preview": "{{#var eventName = generators.eventName(entity.name)}}\n{{#var eventFileName = generators.eventFileName(entity.name)}}\n{{"
},
{
"path": "stubs/make/exception/main.stub",
"chars": 358,
"preview": "{{#var exceptionName = generators.exceptionName(entity.name)}}\n{{#var exceptionFileName = generators.exceptionFileName(e"
},
{
"path": "stubs/make/health/controller.stub",
"chars": 667,
"preview": "{{#var controllerName = generators.controllerName(entity.name, false)}}\n{{#var controllerFileName = generators.controlle"
},
{
"path": "stubs/make/health/main.stub",
"chars": 373,
"preview": "{{#var preloadFileName = string(entity.name).snakeCase().removeExtension().ext('.ts').toString()}}\n{{{\n exports({\n t"
},
{
"path": "stubs/make/listener/for_event.stub",
"chars": 559,
"preview": "{{#var listenerName = generators.listenerName(entity.name)}}\n{{#var listenerFileName = generators.listenerFileName(entit"
},
{
"path": "stubs/make/listener/main.stub",
"chars": 256,
"preview": "{{#var listenerName = generators.listenerName(entity.name)}}\n{{#var listenerFileName = generators.listenerFileName(entit"
},
{
"path": "stubs/make/middleware/main.stub",
"chars": 657,
"preview": "{{#var middlewareName = generators.middlewareName(entity.name)}}\n{{#var middlewareFileName = generators.middlewareFileNa"
},
{
"path": "stubs/make/preload/main.stub",
"chars": 176,
"preview": "{{#var preloadFileName = string(entity.name).snakeCase().removeExtension().ext('.ts').toString()}}\n{{{\n exports({\n t"
},
{
"path": "stubs/make/provider/main.stub",
"chars": 717,
"preview": "{{#var providerName = generators.providerName(entity.name)}}\n{{#var providerFileName = generators.providerFileName(entit"
},
{
"path": "stubs/make/service/main.stub",
"chars": 261,
"preview": "{{#var serviceName = generators.serviceName(entity.name)}}\n{{#var serviceFileName = generators.serviceFileName(entity.na"
},
{
"path": "stubs/make/test/main.stub",
"chars": 343,
"preview": "{{#var testGroupName = generators.testGroupName(entity)}}\n{{#var testFileName = generators.testFileName(entity.name)}}\n{"
},
{
"path": "stubs/make/transformer/main.stub",
"chars": 718,
"preview": "{{#var transformerName = generators.transformerName(entity.name)}}\n{{#var transformerFileName = generators.transformerFi"
},
{
"path": "stubs/make/validator/main.stub",
"chars": 187,
"preview": "{{#var validatorFileName = generators.validatorFileName(entity.name)}}\n{{{\n exports({\n to: app.validatorsPath(entity"
},
{
"path": "stubs/make/validator/resource.stub",
"chars": 745,
"preview": "{{#var validatorName = string(generators.validatorName(entity.name)).noCase()}}\n{{#var validatorFileName = generators.va"
},
{
"path": "stubs/make/view/main.stub",
"chars": 135,
"preview": "{{#var viewFileName = generators.viewFileName(entity.name)}}\n{{{\n exports({\n to: app.viewsPath(entity.path, viewFile"
},
{
"path": "tests/ace/base_command.spec.ts",
"chars": 8419,
"preview": "/*\n * @adonisjs/ace\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * "
},
{
"path": "tests/ace/codemods.spec.ts",
"chars": 13329,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/ace/kernel.spec.ts",
"chars": 3636,
"preview": "/*\n * @adonisjs/ace\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * "
},
{
"path": "tests/bindings/edge.spec.ts",
"chars": 6067,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/bindings/repl.spec.ts",
"chars": 3180,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/bindings/vinejs.spec.ts",
"chars": 6004,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/cli_formatters/routes_list.spec.ts",
"chars": 44242,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/add.spec.ts",
"chars": 11528,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/build.spec.ts",
"chars": 7684,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/configure.spec.ts",
"chars": 12820,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/eject.spec.ts",
"chars": 2031,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/env_add.spec.ts",
"chars": 3891,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/generate_key.spec.ts",
"chars": 2737,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/inspect_rcfile.spec.ts",
"chars": 1435,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_command.spec.ts",
"chars": 1775,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_controller.spec.ts",
"chars": 10959,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_event.spec.ts",
"chars": 1796,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_exception.spec.ts",
"chars": 1897,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_listener.spec.ts",
"chars": 3120,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_middleware.spec.ts",
"chars": 5343,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_preload.spec.ts",
"chars": 5464,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_provider.spec.ts",
"chars": 6092,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_service.spec.ts",
"chars": 1770,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_test.spec.ts",
"chars": 7661,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_transformer.spec.ts",
"chars": 1906,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_validator.spec.ts",
"chars": 2485,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/make_view.spec.ts",
"chars": 1745,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/serve.spec.ts",
"chars": 6110,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/commands/test.spec.ts",
"chars": 8119,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/dumper/dumper.spec.ts",
"chars": 2818,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/encryption/legacy.spec.ts",
"chars": 9261,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/hash.spec.ts",
"chars": 3707,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/helpers.spec.ts",
"chars": 1304,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/helpers.ts",
"chars": 2664,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/ignitor/ace_process.spec.ts",
"chars": 8781,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/ignitor/http_server_process.spec.ts",
"chars": 4961,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/ignitor/main.spec.ts",
"chars": 834,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/ignitor/test_process.spec.ts",
"chars": 1558,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/index_generator.spec.ts",
"chars": 19499,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/pretty_print_error.spec.ts",
"chars": 631,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/providers.spec.ts",
"chars": 14203,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/request_validator.spec.ts",
"chars": 12787,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_command.spec.ts",
"chars": 1261,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_controller.spec.ts",
"chars": 4754,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_event.spec.ts",
"chars": 1253,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_exception.spec.ts",
"chars": 1303,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_listener.spec.ts",
"chars": 1923,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
},
{
"path": "tests/stubs/make_middleware.spec.ts",
"chars": 1458,
"preview": "/*\n * @adonisjs/core\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n *"
}
]
// ... and 26 more files (download for full content)
About this extraction
This page contains the full source code of the adonisjs/core GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 226 files (648.3 KB), approximately 161.1k tokens, and a symbol index with 410 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.