feat: improve monorepo dev experience

This commit is contained in:
2023-10-30 17:31:40 +01:00
parent f65fb52def
commit 8466976b3c
59 changed files with 157 additions and 2662 deletions

View File

@@ -30,8 +30,8 @@
"dependencies": {
"@openstapps/api": "workspace:*",
"@openstapps/api-plugin": "workspace:*",
"@openstapps/json-schema-generator": "workspace:*",
"@openstapps/core": "workspace:*",
"@openstapps/core-tools": "workspace:*",
"@openstapps/logger": "workspace:*",
"commander": "10.0.0",
"express": "4.18.2",
@@ -46,15 +46,6 @@
"tsup": "6.7.0",
"typescript": "5.1.6"
},
"tsup": {
"entry": [
"src/app.ts"
],
"sourcemap": true,
"clean": true,
"format": "esm",
"outDir": "lib"
},
"prettier": "@openstapps/prettier-config",
"eslintConfig": {
"extends": [

View File

@@ -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

View File

@@ -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
*

View File

@@ -27,3 +27,5 @@ export interface SCMinimalRequest {
*/
numbers: number[];
}
export {default as requestSchema} from 'schema:#SCMinimalRequest';

View File

@@ -27,3 +27,5 @@ export interface SCMinimalResponse {
*/
sum: number;
}
export {default as requestSchema} from 'schema:#SCMinimalResponse';

View File

@@ -1,3 +0,0 @@
{
"extends": "@openstapps/tsconfig"
}

View File

@@ -0,0 +1,12 @@
import {defineConfig} from 'tsup';
import {jsonSchemaPlugin} from '@openstapps/json-schema-generator';
export default defineConfig({
entry: ['src/app.ts'],
sourcemap: true,
clean: true,
format: 'esm',
outDir: 'lib',
noExternal: [/.*:schema#.*/],
plugins: [jsonSchemaPlugin('schema.json')],
});