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
CLI project (recommended)
Projects created through CLI come with Server Kit pre-installed, no separate installation required.
Custom project
bash
npm install @genstore/app-server-kitQuick 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
| Parameters | Type | Description |
|---|---|---|
clientID | string | Your app's unique identifier |
clientSecret | string | Secret key for app security |
sessionStorage | SessionStorage | Session storage implementation requiring: - loadSession: Retrieves session data- storeSession: Saves session information - deleteSession: Removes session data |
scopes | string | List of required permission scopes |
appUrl | string | App access URL |
auth.path | string | Authentication path (defaults to '/auth') |
isEmbeddedApp | boolean | Indicates if app is embedded |
useOnlineTokens | boolean | token 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
| Property | Type | Description |
|---|---|---|
accessToken | string | Token for accessing Genstore Open API |
| ... | ... |