cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Designing Service Oriented CAP Plugins

citrus
Associate
Associate
123

I am currently working on a CAP Plugin to call an API oriented service. The purpose of the plugin is to help CAP apps integrate with the service for testing, processing documents as part of a workflow, etc, as the servixe is not currently a CAP app.

Based on the sample plugins provided in the Capire Documentations, the plugins are mostly presented as wrappers/adapters (for example, OData2 Adapter, Auditing), or custom entities (Attachments, Document Management Service). However, I am unable to find sample plugins acting as a service that can be called directly. 

Thus, I would like to ask if there any best practices or examples when it comes to service oriented CAP plugins. Is it best to approach designing the plugin in a similar way as you would be designing a CAP service, and letting the host CAP app treat the CAP plugin similarly to a remote service?

View Entire Topic
MattBrightman
Explorer
0 Kudos

Could you just make a generic npm package rather a CAP Plugin? Could it be similar process for example to the Open AI NPM package: https://www.npmjs.com/package/openai

1. Install - 

npm install openai

2. Import it into your service:

import OpenAI from 'openai';

 3. Use it within your service:

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const response = await client.responses.create({
  model: 'gpt-4o',
  instructions: 'You are a coding assistant that talks like a pirate',
  input: 'Are semicolons optional in JavaScript?',
});