@bunito/bun
v0.0.27
Published
Bun server, secrets integrations, and test doubles for bunito applications.
Maintainers
Readme
@bunito/bun
Bun server and secrets integrations for bunito applications.
It provides platform modules used by higher-level packages, including Bun HTTP server integration and Bun secrets support for configuration readers.
Installation 📦
bun add @bunito/bunUsage ✨
import { BunSecretsModule, BunServerModule } from '@bunito/bun';
import { ConfigModule } from '@bunito/config';
import { Module } from '@bunito/container';
@Module({
imports: [ConfigModule, BunSecretsModule, BunServerModule],
})
class AppModule {}The public names carry the Bun prefix so they stay distinct from framework-level
server or secret abstractions.
Testing 🧪
Importing @bunito/bun registers Bun integration test factories on the shared
@bunito/testing Test context:
Test.BunServerModule: aBunServerModulereplacement wired to a mocked Bun server factory.Test.bunServerFactory: the Bun mock used byBunServerServiceto start the test server.Test.bunServer: aTestBunServerinstance withbuildRequest()andsendRequest()helpers for route tests.Test.BunSecretsModule: aBunSecretsModulereplacement wired to a mocked secrets service.Test.bunSecretsService: a mockedBunSecretsService.
import { App } from '@bunito/bunito';
import { HTTPModule } from '@bunito/http';
import { Test } from '@bunito/testing';
const app = await App.start({
imports: [Test.BunServerModule, Test.LoggerModule, HTTPModule, AppModule],
});
const response = await Test.bunServer
.buildRequest('/orders/ord_1')
.withMethod('GET')
.send();
expect(response.status).toBe(200);
await app.shutdown();TestBunServer simulates Bun route tables, including :param segments and
trailing * wildcards. buildRequest() returns a request builder with
withMethod(), withHeaders(), withBody(), build(), and send() helpers.
License
MIT
