-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from sima-land/38-examples-bun
Шаг 66 #38
- Loading branch information
Showing
13 changed files
with
152 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Handler } from '../../../http'; | ||
|
||
/** | ||
* ВАЖНО: временная экспериментальная утилита, скорее всего будет удалена в будущем. | ||
* @inheritdoc | ||
*/ | ||
export function getStatsHandler(): Handler { | ||
/** @inheritdoc */ | ||
const getHeapStats = async () => { | ||
const jsc = await import( | ||
/* webpackIgnore: true */ | ||
`bun:jsc` | ||
); | ||
|
||
return jsc.heapStats(); | ||
}; | ||
|
||
return async () => { | ||
const stats = await getHeapStats(); | ||
|
||
return new Response(JSON.stringify(stats, null, 2), { | ||
headers: { 'content-type': 'application/json' }, | ||
}); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { ServerHandler } from '../../server/types'; | ||
import { KnownToken } from '../../../tokens'; | ||
import { CURRENT_APP, type Application, type Resolve, Provider } from '../../../di'; | ||
|
||
/** | ||
* Получив фабрику DI-приложения вернёт провайдер обработчика. | ||
* После получения запроса фабрика будет вызвана. | ||
* Далее будет произведена попытка получить компонент обработчика. | ||
* @param getApp Фабрика DI-приложения. | ||
* @return Провайдер обработчика. | ||
*/ | ||
export function HandlerProvider(getApp: () => Application): Provider<ServerHandler> { | ||
return (resolve: Resolve): ServerHandler => { | ||
const parent = resolve(CURRENT_APP); | ||
|
||
return (request, context) => { | ||
const app = getApp(); | ||
|
||
app.attach(parent); | ||
app.bind(KnownToken.Http.Handler.context).toValue({ request, ...context }); | ||
|
||
return app.get(KnownToken.Http.Handler.main)(request, context); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters