-
Notifications
You must be signed in to change notification settings - Fork 65
/
mock-server.js
executable file
·66 lines (56 loc) · 2.55 KB
/
mock-server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
/* eslint global-require: 0 */
var AppControllerSingleton = require('./lib/controller/AppController');
var versionCli = require('./lib/cli/version-cli');
var helpCli = require('./lib/cli/help-cli');
var swaggerImportCli = require('./lib/cli/swagger-import-cli');
var validateCli = require('./lib/cli/validate-cli');
var collectionsCli = require('./lib/cli/collections-cli');
var createDefinedDirectories = require('./lib/commands/create-defined-directories');
var processVersionIndex = process.argv.indexOf('--version');
var processHelpIndex = process.argv.indexOf('--help');
var processSwaggerImportIndex = process.argv.indexOf('swagger-import');
var processValidateIndex = process.argv.indexOf('validate');
var processCollectionsIndex = process.argv.indexOf('collections');
var doExport;
function runServer(options) {
var appController = AppControllerSingleton.getInstance(options);
createDefinedDirectories(appController.options);
var UiController = require('./lib/controller/UiController');
var SchemaController = require('./lib/controller/SchemaController');
var SwaggerImportController = require('./lib/controller/SwaggerImportController');
var DTOController = require('./lib/controller/DTOController');
var ResponseController = require('./lib/controller/ResponseController');
var PreferencesController = require('./lib/controller/PreferencesController');
var ValidatorController = require('./lib/controller/ValidatorController');
var CollectionController = require('./lib/controller/CollectionController');
var FileOpenController = require('./lib/controller/FileOpenController');
var MockController = require('./lib/controller/MockController');
return {
appController: appController,
uiController: new UiController(),
schemaController: new SchemaController(),
swaggerImportController: new SwaggerImportController(),
dtoController: new DTOController(),
ResponseController: new ResponseController(),
preferencesController: new PreferencesController(),
validatorController: new ValidatorController(),
collectionController: new CollectionController(),
fileOpenController: new FileOpenController(),
mockController: new MockController(),
};
}
if (processVersionIndex >= 0) {
doExport = versionCli;
} else if (processHelpIndex >= 0) {
doExport = helpCli;
} else if (processCollectionsIndex >= 0) {
doExport = collectionsCli;
} else if (processSwaggerImportIndex >= 0) {
doExport = swaggerImportCli;
} else if (processValidateIndex >= 0) {
doExport = validateCli.bind(null, runServer);
} else {
doExport = runServer;
}
module.exports = doExport;