@pageloop/server
v0.6.1
Published
The Node backend for [PageLoop](https://github.com/rw3iss/pageloop) — a framework-agnostic `Application` core plus the transport adapters that expose it over HTTP. Pure TypeScript; you inject persistence/mail/payment adapters and pick a transport.
Downloads
979
Readme
@pageloop/server
The Node backend for PageLoop — a
framework-agnostic Application core plus the transport adapters that expose it
over HTTP. Pure TypeScript; you inject persistence/mail/payment adapters and
pick a transport.
Install
pnpm add @pageloop/serverFor the /nestjs subpath you also need NestJS in your app — @nestjs/common,
@nestjs/core, @nestjs/platform-ws, @nestjs/websockets, reflect-metadata,
and rxjs are optional peer dependencies, only required when you mount the
NestJS module.
Exports
| Subpath | Use when |
|---|---|
| . | The framework-agnostic Application (handlers, Policy, EventBus, AuthService, scope guards). Plain TS — no HTTP framework imported. |
| /http | Standalone node:http + ws + SSE transport adapter (createServer). The default self-host transport. |
| /nestjs | PageLoopModule.forRoot({ app, basePath }) — a NestJS DynamicModule that mounts the handlers inside an existing NestJS app. |
. — build an Application
Wire the core with injected adapters; it holds the handlers, policy, event bus,
and auth, and exposes dispatch(method, params, ctx):
import { Application } from '@pageloop/server';
import { createSqliteAdapter } from '@pageloop/persistence';
import { createConsoleMailAdapter } from '@pageloop/mail';
const app = new Application(
{ persistence: createSqliteAdapter({ file: 'pageloop.db' }), mail: createConsoleMailAdapter() },
{ jwtSecret: process.env.PAGELOOP_JWT_SECRET! },
);
await app.migrate();/http — standalone server
Hand the Application to the bundled node:http + WebSocket + SSE transport.
This is what pageloop serve runs:
import { createServer } from '@pageloop/server/http';
const server = createServer({ app, port: 4317 });
server.listen();/nestjs — mount inside an existing NestJS app
import { Module } from '@nestjs/common';
import { PageLoopModule } from '@pageloop/server/nestjs';
@Module({
imports: [PageLoopModule.forRoot({ app, basePath: '/api/v1' })],
})
export class AppModule {}The module registers a controller + WS gateway that proxy traffic to
Application.dispatch — same single-dispatch pattern as /http. Auth,
validation, and business logic stay in the core.
