update initial test
This commit is contained in:
@ -1 +1 @@
|
||||
export * from './smartuniverse.classes.smartuniverse';
|
||||
export * from './smartuniverse.classes.smartuniverse';
|
||||
|
@ -1,5 +1,42 @@
|
||||
import * as plugins from './smartuniverse.plugins';
|
||||
|
||||
export Smartuniverse {
|
||||
|
||||
}
|
||||
import { Handler, Route, Server } from 'smartexpress';
|
||||
|
||||
import * as paths from './smartuniverse.paths';
|
||||
|
||||
export interface ISmartUniverseConstructorOptions {
|
||||
port: number | string;
|
||||
}
|
||||
|
||||
export class SmartUniverse {
|
||||
private options: ISmartUniverseConstructorOptions;
|
||||
private universeVersionStore: string;
|
||||
private get universeVersion() {
|
||||
if (this.universeVersionStore) {
|
||||
return this.universeVersionStore;
|
||||
} else {
|
||||
const packageJson = plugins.smartfile.fs.toObjectSync(paths.packageJson);
|
||||
this.universeVersionStore = packageJson.version;
|
||||
return this.universeVersionStore;
|
||||
}
|
||||
}
|
||||
private smartexpressServer: plugins.smartexpress.Server;
|
||||
constructor(optionsArg: ISmartUniverseConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
public async init() {
|
||||
this.smartexpressServer = new plugins.smartexpress.Server({
|
||||
cors: true,
|
||||
defaultAnswer: `smartuniverse server ${this.universeVersion}`,
|
||||
forceSsl: false,
|
||||
port: this.options.port
|
||||
});
|
||||
|
||||
const addRoute = new Route(this.smartexpressServer, 'addMessage');
|
||||
const addHandler = new Handler('PUT', requestBody => {
|
||||
return 'hi';
|
||||
});
|
||||
// await this.smartexpressServer.addRoute()
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
import * as plugins from './smartuniverse.plugins';
|
||||
|
||||
import { SmartUniverse } from './index';
|
||||
|
||||
process.env.CLI = 'true';
|
||||
|
||||
const universeCli = new plugins.smartcli.Smartcli();
|
||||
|
||||
universeCli.standardTask().then(argvArg => {
|
||||
|
||||
});
|
||||
const standardUniverse = new SmartUniverse({
|
||||
port: 8765
|
||||
});
|
||||
});
|
||||
|
3
ts/smartuniverse.paths.ts
Normal file
3
ts/smartuniverse.paths.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as plugins from './smartuniverse.plugins';
|
||||
|
||||
export const packageJson = plugins.path.join(__dirname, '../package.json');
|
@ -1,4 +1,6 @@
|
||||
import * as path from 'path';
|
||||
import * as smartcli from 'smartcli';
|
||||
import * as smartexpress from 'smartexpress';
|
||||
import * as smartfile from 'smartfile';
|
||||
|
||||
export { smartcli, smartexpress };
|
||||
export { path, smartcli, smartexpress, smartfile };
|
||||
|
Reference in New Issue
Block a user