mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: improve monorepo dev experience
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import {HttpClient} from '@openstapps/api';
|
||||
import {PluginClient} from '@openstapps/api-plugin';
|
||||
import {Converter} from '@openstapps/core-tools';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Command, Option} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
@@ -52,18 +51,11 @@ const pluginClient = new PluginClient(new HttpClient(), options.backendUrl);
|
||||
|
||||
// create an instance of your plugin
|
||||
const plugin = new MinimalPlugin(
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
Number.parseInt(options.port, 10),
|
||||
options.pluginName,
|
||||
options.url,
|
||||
`/${options.routeName}`,
|
||||
options.backendUrl,
|
||||
new Converter(path.resolve(__dirname, '..', 'src', 'plugin', 'protocol')), // an instance of the converter. Required
|
||||
// because your requests and response schemas are defined in the plugin. The path should lead to your request and
|
||||
// response interfaces
|
||||
'SCMinimalRequest', // TODO: adjust name of the request interface
|
||||
'SCMinimalResponse', // TODO: adjust name of the response interface
|
||||
JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json')).toString()).version, // get the version of the plugin from the package.json
|
||||
);
|
||||
|
||||
pluginClient
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
import {Plugin} from '@openstapps/api-plugin';
|
||||
import * as express from 'express';
|
||||
import schema from '../../lib/schema.json';
|
||||
import {SCMinimalRequest} from './protocol/request.js';
|
||||
import {SCMinimalResponse} from './protocol/response.js';
|
||||
|
||||
@@ -24,6 +25,10 @@ import {SCMinimalResponse} from './protocol/response.js';
|
||||
* TODO: rename the class
|
||||
*/
|
||||
export class MinimalPlugin extends Plugin {
|
||||
requestSchema = schema.SCMinimalRequest;
|
||||
|
||||
responseSchema = schema.SCMinimalResponse;
|
||||
|
||||
/**
|
||||
* Calculates the sum of a list of numbers
|
||||
*
|
||||
|
||||
@@ -27,3 +27,5 @@ export interface SCMinimalRequest {
|
||||
*/
|
||||
numbers: number[];
|
||||
}
|
||||
|
||||
export {default as requestSchema} from 'schema:#SCMinimalRequest';
|
||||
|
||||
@@ -27,3 +27,5 @@ export interface SCMinimalResponse {
|
||||
*/
|
||||
sum: number;
|
||||
}
|
||||
|
||||
export {default as requestSchema} from 'schema:#SCMinimalResponse';
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
Reference in New Issue
Block a user