This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/api/bin/console.ts
Théo LUDWIG 4add77856e
All checks were successful
Chromatic / chromatic (push) Successful in 2m58s
CI / ci (push) Successful in 4m43s
CI / commitlint (push) Successful in 15s
chore: try Adonis Tuyau
2024-08-16 01:50:11 +01:00

49 lines
1.3 KiB
JavaScript
Executable File

#!/usr/bin/env -S node --import=tsx
/**
* Ace entry point
*
* Entrypoint for booting the AdonisJS command-line framework and executing commands.
* Commands do not boot the application, unless the currently running command has `options.startApp` flag set to true.
*/
import { Ignitor, prettyPrintError } from "@adonisjs/core"
import "reflect-metadata"
/**
* URL to the application root. AdonisJS need it to resolve paths to file and directories for scaffolding commands
*/
const APP_ROOT = new URL("../", import.meta.url)
/**
* The importer is used to import files in context of the application.
*/
const IMPORTER = async (filePath: string): Promise<unknown> => {
if (filePath.startsWith("./") || filePath.startsWith("../")) {
return await import(new URL(filePath, APP_ROOT).href)
}
return await import(filePath)
}
const ignitor = new Ignitor(APP_ROOT, { importer: IMPORTER })
try {
await ignitor
.tap((app) => {
app.booting(async () => {
await import("#start/env.ts")
})
app.listen("SIGTERM", async () => {
return await app.terminate()
})
app.listenIf(app.managedByPm2, "SIGINT", async () => {
return await app.terminate()
})
})
.ace()
.handle(process.argv.splice(2))
} catch (error) {
process.exitCode = 1
await prettyPrintError(error)
}