Skip to content

Server kit development guide ​

Server Kit is the server-side component of the Genstore SDK, providing core functionalities such as authentication management and session handling - essential building blocks for Genstore appWlications.

Installation ​

Projects created through CLI come with Server Kit pre-installed, no separate installation required.

Custom project ​

bash
npm install @genstore/app-server-kit

Quick start ​

Creat an app instance ​

Use ServerApp to create and configure your app instance:

jsx
import { ServerApp } from '@genstore/app-server-kit';
import { MemorySessionStorage } from '@genstore/app-server-kit/utils';

const blazeApp = ServerApp({
  clientID: process.env.DevClientID || '',
  clientSecret: process.env.DevClientSecret || '',
  sessionStorage: new MemorySessionStorage(),
  scopes: process.env.SCOPES?.split(','),
  appUrl: process.env.APP_URL || '',
  auth: {
    path: '/auth',
  },
  isEmbeddedApp: true,
  useOnlineTokens: false,
});

TIP

Initialize your app instance once and export it during startup. Avoid creating multiple instances across your codebase.

Configuration options ​

ParametersTypeDescription
clientIDstringYour app's unique identifier
clientSecretstringSecret key for app security
sessionStorageSessionStorageSession storage implementation requiring:
- loadSession: Retrieves session data
- storeSession: Saves session information
- deleteSession: Removes session data
scopesstringList of required permission scopes
appUrlstringApp access URL
auth.pathstringAuthentication path (defaults to '/auth')
isEmbeddedAppbooleanIndicates if app is embedded
useOnlineTokensbooleantoken mode:
- true: Online tokens
- false: Offline tokens

Core API reference ​

blazeApp.authenticate(request: Request) ​

Handles request authentication and retrieves session information. Failed authentication automatically redirects to auth.path.

Returns: Session object

PropertyTypeDescription
accessTokenstringToken for accessing Genstore Open API
......