Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
ef568f2aa2 | |||
fced92e1cc | |||
f73334d8fc | |||
d170af1db5 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiglobal/sdk",
|
"name": "@apiglobal/sdk",
|
||||||
"version": "1.0.9",
|
"version": "1.0.11",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiglobal/sdk",
|
"name": "@apiglobal/sdk",
|
||||||
"version": "1.0.9",
|
"version": "1.0.11",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "an sdk package for api.global",
|
"description": "an sdk package for api.global",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
17
test/test.ts
17
test/test.ts
@ -8,6 +8,7 @@ tap.test('should create a valid Handler', async () => {
|
|||||||
class MyHandler extends sdk.AAgHandler<any> {
|
class MyHandler extends sdk.AAgHandler<any> {
|
||||||
public slug: 'testapi';
|
public slug: 'testapi';
|
||||||
public typedrouter = new TypedRouter();
|
public typedrouter = new TypedRouter();
|
||||||
|
|
||||||
public async checkReqirements() {
|
public async checkReqirements() {
|
||||||
return {
|
return {
|
||||||
allOk: true,
|
allOk: true,
|
||||||
@ -18,9 +19,23 @@ tap.test('should create a valid Handler', async () => {
|
|||||||
public async start() {}
|
public async start() {}
|
||||||
|
|
||||||
public async stop() {}
|
public async stop() {}
|
||||||
|
|
||||||
|
public async checkRequirements(): Promise<sdk.IRequirementResult> {
|
||||||
|
return {
|
||||||
|
allOk: true,
|
||||||
|
reason: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const myHandlerInstance = new MyHandler();
|
// tslint:disable-next-line: max-classes-per-file
|
||||||
|
class AgEnvironement extends sdk.AgEnvironment {
|
||||||
|
public async getEnvVar(nameArg: string) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const myHandlerInstance = new MyHandler(new AgEnvironement());
|
||||||
|
|
||||||
expect(myHandlerInstance).to.be.instanceOf(sdk.AAgHandler);
|
expect(myHandlerInstance).to.be.instanceOf(sdk.AAgHandler);
|
||||||
});
|
});
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
export * from './sdk.classes.agenvironment';
|
||||||
export * from './sdk.classes.aghandler';
|
export * from './sdk.classes.aghandler';
|
||||||
export * from './sdk.classes.authinfo';
|
export * from './sdk.classes.authinfo';
|
||||||
|
8
ts/sdk.classes.agenvironment.ts
Normal file
8
ts/sdk.classes.agenvironment.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as plugins from './sdk.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AgEnvironment handles the provision of environment variables to handlers
|
||||||
|
*/
|
||||||
|
export abstract class AgEnvironment {
|
||||||
|
public abstract async getEnvVar(envVarName: string): Promise<string>;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './sdk.plugins';
|
import * as plugins from './sdk.plugins';
|
||||||
import { AuthInfo } from './sdk.classes.authinfo';
|
import { AuthInfo } from './sdk.classes.authinfo';
|
||||||
|
import { AgEnvironment } from './sdk.classes.agenvironment';
|
||||||
|
|
||||||
export interface IRequirementResult {
|
export interface IRequirementResult {
|
||||||
allOk: boolean;
|
allOk: boolean;
|
||||||
@ -7,6 +8,8 @@ export interface IRequirementResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export abstract class AAgHandler<TClaim> {
|
export abstract class AAgHandler<TClaim> {
|
||||||
|
public agEnvironment: AgEnvironment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a slug that separates the handler from other handlers
|
* a slug that separates the handler from other handlers
|
||||||
*/
|
*/
|
||||||
@ -14,6 +17,10 @@ export abstract class AAgHandler<TClaim> {
|
|||||||
public abstract typedrouter: plugins.typedrequest.TypedRouter;
|
public abstract typedrouter: plugins.typedrequest.TypedRouter;
|
||||||
public abstract checkRequirements(): Promise<IRequirementResult>;
|
public abstract checkRequirements(): Promise<IRequirementResult>;
|
||||||
|
|
||||||
|
constructor(agEnvironmentArg: AgEnvironment) {
|
||||||
|
this.agEnvironment = agEnvironmentArg;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start the ag-handler
|
* start the ag-handler
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user