Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "5.20.0",
"version": "5.21.0",
"description": "One foundation for multiple applications.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
19 changes: 17 additions & 2 deletions src/applications/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import { Is, Path, Module, Options } from '@athenna/common'

export class Http {
/**
* Boot the Http application.
* Only initialize the server without booting it.
*/
public static async boot(options?: HttpOptions): Promise<ServerImpl> {
public static async init(options?: HttpOptions): Promise<ServerImpl> {
options = Options.create(options, {
initOnly: false,
host: Config.get('http.host', '127.0.0.1'),
port: Config.get('http.port', 3000),
routePath: Config.get('rc.http.route', Path.routes(`http.${Path.ext()}`)),
Expand All @@ -37,6 +38,20 @@ export class Http {
ioc.safeUse('Athenna/Core/HttpRoute').register()

await server.viteReady()

return server
}

/**
* Boot the Http application.
*/
public static async boot(options?: HttpOptions): Promise<ServerImpl> {
const server = await this.init(options)

if (options.initOnly) {
return server
}

await server.listen({ host: options.host, port: options.port })

if (Config.notExists('rc.bootLogs') || Config.is('rc.bootLogs', false)) {
Expand Down
8 changes: 8 additions & 0 deletions src/types/HttpOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
*/

export type HttpOptions = {
/**
* Only initialize the server without booting it. Useful when you want to
* deploy your application in a serverless environment.
*
* @default false
*/
initOnly?: boolean

/**
* The host where the server will run. By default Athenna will read the "http.host" config
* to get this information, but you can set here and subscribe this behavior.
Expand Down
Loading