The server creates one object and mounts its routes.
import express from 'express';
import { createCrm, createMemoryStores, toNodeListener } from '@ilanoh/crm';
import { authorize, sessionActor } from './crm-policy.js';
export const crm = await createCrm({
...createMemoryStores(),
keys: { k1: process.env.CRM_KEY },
active_key_id: 'k1',
redirect_base_url: `${process.env.APP_URL}/crm`,
return_to_allowlist: [`${process.env.APP_URL}/settings/`],
base_path: '/crm',
connectors: ['hubspot'],
oauth: {
hubspot: {
client_id: process.env.HUBSPOT_CLIENT_ID,
client_secret: process.env.HUBSPOT_CLIENT_SECRET,
},
},
authenticateRequest: sessionActor,
authorize,
});
const app = express();
app.use(toNodeListener(crm.handlers));
Memory stores suit a test. Production uses the Postgres or Mongo stores, which sit in your own database. Your two functions, authenticateRequest and authorize, plug the SDK into your existing login and permissions. Quickstarts cover Express, Fastify, Django, React and plain HTML.
In the browser, your user clicks a connect button, a web component.
<crm-connect base-path="/crm" lang="en" status-model="contact"></crm-connect>
The component ships with a React wrapper and a headless core, so it can adopt your design.