forked from smollweide/node-mock-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
69 lines (63 loc) · 1.56 KB
/
options.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
67
68
69
'use strict';
var dest = __dirname + '/rest';
var replacePathsStr = '/v2/{baseSiteId}';
var responseFuncPath = __dirname + '/func-imported';
// http://petstore.swagger.io/v2/swagger.json
// http://localhost:3001/src/swagger/swagger-demo-docs.json
module.exports = {
restPath: dest,
dirName: __dirname,
uiPath: '/',
funcPath: [
__dirname + '/func',
__dirname + '/func2',
responseFuncPath,
],
headers: {
'Global-Custom-Header': 'Global-Custom-Header',
},
customDTOToClassTemplate: __dirname + '/templates/dto_es6flow.ejs',
optionsFallbackPath: __dirname + '/rest/_fallbacks/#/OPTIONS/',
middleware: {
'/rest/products/#{productCode}/GET'(serverOptions, requestOptions) {
var productCode = requestOptions.req.params[0].split('/')[3];
if (productCode === '1234') {
requestOptions.res.statusCode = 201;
requestOptions.res.end('product 1234');
return null;
}
return 'success';
}
},
expressMiddleware: [
function (express) {
return ['/public', express.static(__dirname + '/public')];
}
],
swaggerImport: {
protocol: 'http',
authUser: undefined,
authPass: undefined,
host: 'petstore.swagger.io',
port: 80,
path: '/v2/swagger.json',
dest: dest,
replacePathsStr: replacePathsStr,
createErrorFile: true,
createEmptyFile: true,
overwriteExistingDescriptions: true,
responseFuncPath: responseFuncPath,
},
open: true,
tunnel: {
protocol: 'http',
authUser: undefined,
authPass: undefined,
host: 'localhost',
port: 3333,
requestHeaders: {
host: 'www.test.com',
referer: "http://www.test.com/",
},
}
}