You are viewing the Akan.js v1 docs.Go to the latest v2 docs

model.signal.ts

Signals define the external interface of your module. They connect your Service logic to the outside world via various protocols (HTTP, GQL, WebSocket).
📡Three Signal Types
  • Internal: Background tasks, cron jobs
  • Endpoint: Public API (REST/GQL, WebSocket)
  • Slice: Frontend-facing data subsets

Defining Internal Tasks

Use internal() to define background tasks like cron jobs or process queues that run independently of user requests.
interval(ms)
Defines a recurring task executed every 'ms' milliseconds.
process(ReturnType)
Defines a background process queue handled by a worker.
product.signal.ts

Defining Public APIs

Use endpoint() to define standard API methods. You can mix Query, Mutation, and Real-time subscriptions.
Method Types
query(ReturnType, options?)
Defines a GraphQL Query or HTTP GET endpoint.
mutation(ReturnType, options?)
Defines a GraphQL Mutation or HTTP POST endpoint.
message(ReturnType, options?)
Defines a WebSocket message handler.
pubsub(payloadType)
Defines a PubSub topic handler.
Parameter Builders
Parameters are strictly scoped. For example, you cannot use .room() in a Query or .body() in a Subscription.
.param(name, Type, options?)
Required path parameter. (Available in: Query, Mutation, Process)
.search(name, Type, options?)
Query string or optional argument. (Available in: Query, Mutation)
.body(name, Type, options?)
Request body parameter. (Available in: Mutation)
.msg(name, Type, options?)
Message payload field. (Available in: Message)
.room(name, Type, options?)
PubSub room identifier. (Available in: PubSub)
Chat Example
Client Usage (fetch)
Use the fetch object to call endpoint methods on the client.
Client Usage

Standard Model APIs

The following methods are automatically generated for every model and are available via the fetch object.
view[Model](id: string): Promise<ViewReturn>
Fetch detail view data. Returns { [Model], [Model]View }.
edit[Model](id: string): Promise<EditReturn>
Fetch data for editing. Returns { [Model], [Model]Edit }.
merge[Model](id: string | null, data: Partial<Model>): Promise<Model>
Create or Update model data. Returns updated Model.

Defining Slices & Stores

Use slice() to group APIs for specific contexts (e.g., 'My Tickets', 'Project Tickets'). It automatically generates client-side stores and pagination Actions.
⚡Automation Power
Defining a slice automatically creates fetch.init[SliceName] on the client. It handles data loading, pagination, and state management in one go.
Server Definition
ticket.signal.ts
Slice Auto-Generated Methods
Methods generated specifically for each slice definition.
[Model]List[Suffix](...args, skip, limit, sort): Promise<Model[]>
Get list of data with pagination arguments. Returns Model array.
[Model]Insight[Suffix](...args): Promise<Insight>
Get aggregated statistics. Returns Insight object.
init[Model](query?, option?): Promise<InitReturn>
Initialize list with default options. Returns { [Model]Init, [Model]List, [Model]Insight }.
init[SliceName](...args): Promise<InitReturn>
Initialize slice list data. Returns { [Slice]Init, [Slice]List, [Slice]Insight }.
Client Usage
Client Page (page.tsx)

Using & Defining Guards

Guards protect your Signals. You can use built-in guards or define your own by implementing the Guard interface.
Creating a Custom Guard
canActivate(context)
Returns boolean indicating if the request is allowed.
getRequest(context)
Helper to extract the request object, including the user account.
libs/shared/nest/authGuards.ts
Applying Guards

Released under the MIT License

Connect your AI to these docs

MCPhttps://akanjs.com/mcp
Copyright © 2026 Akan.js All rights reserved.System managed bybassman