Primeros pasos
Instala solo las piezas que necesites. Un servicio HTTP habitual parte de @go-like/context, @go-like/core, @go-like/web y un framework que exponga un handler Fetch nativo. Para llamadas internas añade @go-like/client, @go-like/transport y @go-like/transport-http; el registro, la configuración y el almacén se eligen de forma explícita.
IMPORTANT
Este checkout usa paquetes workspace:* en versión 0.0.1. La versión del manifest no demuestra disponibilidad en npm; comprueba la publicación antes de instalar fuera del workspace.
bun install --frozen-lockfile
bun run test:e2e:examples
bun run --cwd examples/vanilla-web startbun add @go-like/context @go-like/core @go-like/webCrea src/main.ts:
import process from "node:process"
import { background } from "@go-like/context"
import { afterStart, context, name, newApp, server, stopTimeout } from "@go-like/core"
import { signal } from "@go-like/core/node"
import type { Handler } from "@go-like/web"
import { newNodeServer, port } from "@go-like/web/node"
const handler: Handler = (request) => {
const path = new URL(request.url).pathname
return Response.json({ message: "hello from go-like", path })
}
const webServer = newNodeServer(handler, port(3000))
const app = newApp(
context(background()),
name("hello"),
server(webServer),
stopTimeout(30_000),
signal(),
afterStart(async function announceReady(ctx): Promise<void> {
await webServer.endpoint(ctx)
process.stdout.write("GO_LIKE_EXAMPLE_READY=hello\n")
})
)
await app.run()Ejecuta el servicio:
bun run src/main.tsEspera la línea GO_LIKE_EXAMPLE_READY=hello antes de enviar tráfico. Cualquier objeto que cumpla estructuralmente la interfaz Server cabe en la aplicación. @go-like/croner, @go-like/bullmq, @go-like/pino y @go-like/winston ya conectan bibliotecas conocidas, pero no vuelven a inventar todas sus opciones.
La aplicación sigue creando conexiones, credenciales, rutas y configuración del framework. Pasa a go-like la capacidad mínima, normalmente un objeto nativo o una función fetch. Así las pruebas se controlan mejor y al apagar queda claro quién debe cerrar cada recurso.