fix(core): update
This commit is contained in:
		
							
								
								
									
										654
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										654
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										16
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								package.json
									
									
									
									
									
								
							@@ -9,18 +9,20 @@
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "(tstest test/ --web)",
 | 
			
		||||
    "build": "(tsbuild --web)",
 | 
			
		||||
    "format": "(gitzone format)"
 | 
			
		||||
    "build": "(tsbuild --web)"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@gitzone/tsbuild": "^2.0.22",
 | 
			
		||||
    "@gitzone/tstest": "^1.0.15",
 | 
			
		||||
    "@pushrocks/tapbundle": "^3.0.7",
 | 
			
		||||
    "@types/node": "^10.11.7",
 | 
			
		||||
    "tslint": "^5.11.0",
 | 
			
		||||
    "tslint-config-prettier": "^1.15.0"
 | 
			
		||||
    "@types/node": "^14.0.14",
 | 
			
		||||
    "tslint": "^6.1.2",
 | 
			
		||||
    "tslint-config-prettier": "^1.18.0"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@apiglobal/sdk": "^1.0.9",
 | 
			
		||||
    "@pushrocks/smartexpress": "^3.0.73"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {},
 | 
			
		||||
  "files": [
 | 
			
		||||
    "ts/**/*",
 | 
			
		||||
    "ts_web/**/*",
 | 
			
		||||
@@ -33,4 +35,4 @@
 | 
			
		||||
    "npmextra.json",
 | 
			
		||||
    "readme.md"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,10 @@
 | 
			
		||||
import { expect, tap } from '@pushrocks/tapbundle';
 | 
			
		||||
import * as testSdk from '../ts/index';
 | 
			
		||||
 | 
			
		||||
let testServer: testSdk.AgTestServer;
 | 
			
		||||
 | 
			
		||||
tap.test('first test', async () => {
 | 
			
		||||
  console.log(testSdk.standardExport);
 | 
			
		||||
  console.log('TODO');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
tap.start();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								ts/index.ts
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								ts/index.ts
									
									
									
									
									
								
							@@ -1,3 +1,17 @@
 | 
			
		||||
import * as plugins from './test-sdk.plugins';
 | 
			
		||||
import { AgTestServer } from './test-sdk.classes.testserver';
 | 
			
		||||
 | 
			
		||||
export let standardExport = 'Hi there! :) This is an exported string';
 | 
			
		||||
export { AgTestServer };
 | 
			
		||||
 | 
			
		||||
let testServer: AgTestServer;
 | 
			
		||||
export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>) => {
 | 
			
		||||
  testServer = new AgTestServer(handlerArg);
 | 
			
		||||
  await testServer.start();
 | 
			
		||||
  return testServer;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const stopTestServer = async () => {
 | 
			
		||||
  if (testServer) {
 | 
			
		||||
    await testServer.stop();
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										42
									
								
								ts/test-sdk.classes.testserver.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								ts/test-sdk.classes.testserver.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
import * as plugins from './test-sdk.plugins';
 | 
			
		||||
 | 
			
		||||
export class AgTestServer {
 | 
			
		||||
  public handlers: Array<plugins.agSdk.AAgHandler<any>> = [];
 | 
			
		||||
  public server: plugins.smartexpress.Server;
 | 
			
		||||
 | 
			
		||||
  constructor(handlerArg?: plugins.agSdk.AAgHandler<any>) {
 | 
			
		||||
    if (handlerArg) {
 | 
			
		||||
      this.handlers.push(handlerArg);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async addAgHandler(handlerArg: plugins.agSdk.AAgHandler<any>) {
 | 
			
		||||
    this.handlers.push(handlerArg);
 | 
			
		||||
    await this.stop();
 | 
			
		||||
    await this.start();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async start() {
 | 
			
		||||
    this.server = new plugins.smartexpress.Server({
 | 
			
		||||
      cors: true,
 | 
			
		||||
      defaultAnswer: async () => 'apiglobal testserver',
 | 
			
		||||
      domain: 'localhost',
 | 
			
		||||
      forceSsl: false,
 | 
			
		||||
    });
 | 
			
		||||
    for (const handlerArg of this.handlers) {
 | 
			
		||||
      this.server.addRoute(
 | 
			
		||||
        `/${handlerArg.slug}`,
 | 
			
		||||
        new plugins.smartexpress.HandlerTypedRouter(handlerArg.typedrouter)
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async stop() {
 | 
			
		||||
    if (this.server) {
 | 
			
		||||
      const previousServer = this.server;
 | 
			
		||||
      this.server = null;
 | 
			
		||||
      await this.server.startedPromise;
 | 
			
		||||
      await this.server.stop();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,2 +1,9 @@
 | 
			
		||||
const removeme = {};
 | 
			
		||||
export { removeme };
 | 
			
		||||
// apiglobal scope
 | 
			
		||||
import * as agSdk from '@apiglobal/sdk';
 | 
			
		||||
 | 
			
		||||
export { agSdk };
 | 
			
		||||
 | 
			
		||||
// pushrocks scope
 | 
			
		||||
import * as smartexpress from '@pushrocks/smartexpress';
 | 
			
		||||
 | 
			
		||||
export { smartexpress };
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user