-
Notifications
You must be signed in to change notification settings - Fork 1
api server HowTo
GitHub Action edited this page May 21, 2026
·
1 revision
The @quatrain/api-server package provides agnostic HTTP endpoints (like CrudEndpoint, ListEndpoint, ValuesEndpoint) that can be used with any web server adapter (such as @quatrain/api-server-express).
You can bind full CRUD endpoints to a specific model.
import { CrudEndpoint, ListEndpoint } from '@quatrain/api-server';
// You must use an adapter, like ExpressAdapter from @quatrain/api-server-express
import { ExpressAdapter } from '@quatrain/api-server-express';
import { StudioModel } from '@quatrain/studio';
const server = new ExpressAdapter();
// Create a GET /api/models endpoint to list models
server.addEndpoint(
'/api/models',
ListEndpoint(StudioModel)
);
// Create full POST, GET, PUT, DELETE for individual models
server.addEndpoint(
'/api/models',
CrudEndpoint(StudioModel),
{ methods: ['CREATE', 'READ', 'UPDATE', 'DELETE'] }
);