-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement haku selection and use mock server for testing
- Loading branch information
1 parent
411c406
commit 08fb526
Showing
16 changed files
with
4,631 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://www.mocks-server.org/docs/configuration/how-to-change-settings | ||
// https://www.mocks-server.org/docs/configuration/options | ||
|
||
module.exports = { | ||
// Log level. Can be one of silly, debug, verbose, info, warn or error | ||
//log: "info", | ||
config: { | ||
// Allow unknown arguments | ||
//allowUnknownArguments: false, | ||
}, | ||
plugins: { | ||
// Plugins to be registered | ||
//register: [], | ||
proxyRoutesHandler: { | ||
}, | ||
adminApi: { | ||
// Port number for the admin API server to be listening at | ||
//port: 3110, | ||
// Host for the admin API server | ||
//host: "0.0.0.0", | ||
https: { | ||
// Use https protocol or not | ||
//enabled: false, | ||
// Path to a TLS/SSL certificate | ||
//cert: undefined, | ||
// Path to the certificate private key | ||
//key: undefined, | ||
}, | ||
}, | ||
inquirerCli: { | ||
// Start interactive CLI or not | ||
//enabled: true, | ||
// Render emojis or not | ||
//emojis: true, | ||
}, | ||
openapi: { | ||
collection: { | ||
// Name for the collection created from OpenAPI definitions | ||
//id: "openapi", | ||
// Name of the collection to extend from | ||
//from: undefined, | ||
}, | ||
}, | ||
}, | ||
mock: { | ||
routes: { | ||
// Global delay to apply to routes | ||
//delay: 0, | ||
}, | ||
collections: { | ||
// Selected collection | ||
//selected: "base", | ||
}, | ||
}, | ||
server: { | ||
// Port number for the server to be listening at | ||
port: 3104, | ||
// Host for the server | ||
//host: "0.0.0.0", | ||
cors: { | ||
// Use CORS middleware or not | ||
//enabled: true, | ||
// Options for the CORS middleware. Further information at https://github.com/expressjs/cors#configuration-options | ||
//options: {"preflightContinue":false}, | ||
}, | ||
jsonBodyParser: { | ||
// Use json body-parser middleware or not | ||
//enabled: true, | ||
// Options for the json body-parser middleware. Further information at https://github.com/expressjs/body-parser | ||
//options: {}, | ||
}, | ||
urlEncodedBodyParser: { | ||
// Use urlencoded body-parser middleware or not | ||
//enabled: true, | ||
// Options for the urlencoded body-parser middleware. Further information at https://github.com/expressjs/body-parser | ||
//options: {"extended":true}, | ||
}, | ||
https: { | ||
// Use https protocol or not | ||
//enabled: false, | ||
// Path to a TLS/SSL certificate | ||
//cert: undefined, | ||
// Path to the certificate private key | ||
//key: undefined, | ||
}, | ||
}, | ||
files: { | ||
// Allows to disable files load | ||
//enabled: true, | ||
// Define folder from where to load collections and routes | ||
//path: "mocks", | ||
// Enable/disable files watcher | ||
//watch: true, | ||
babelRegister: { | ||
// Load @babel/register | ||
//enabled: false, | ||
// Options for @babel/register | ||
//options: {}, | ||
}, | ||
}, | ||
variantHandlers: { | ||
// Variant Handlers to be registered | ||
//register: [], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[ | ||
{ | ||
"id": "base", | ||
"routes": ["add-headers:enabled", "get-users:success", "get-user:success", "get-haut:success"] | ||
}, | ||
{ | ||
"id": "no-headers", | ||
"from": "base", | ||
"routes": ["add-headers:disabled"] | ||
}, | ||
{ | ||
"id": "all-users", | ||
"from": "base", | ||
"routes": ["get-users:all", "get-user:id-3"] | ||
}, | ||
{ | ||
"id": "user-real", | ||
"from": "no-headers", | ||
"routes": ["get-user:real"] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Use this file only as a guide for first steps using middleware variants. You can delete it when you have understood the concepts. | ||
// For a detailed explanation about using middlewares, visit: | ||
// https://mocks-server.org/docs/usage/variants/middlewares | ||
|
||
module.exports = [ | ||
{ | ||
id: "add-headers", //route id | ||
url: "*", // url in express format | ||
method: ["GET", "POST", "PUT", "PATCH"], // HTTP methods | ||
variants: [ | ||
{ | ||
id: "enabled", // variant id | ||
type: "middleware", // variant handler id | ||
options: { | ||
// Express middleware to execute | ||
middleware: (_req, res, next, core) => { | ||
res.set("x-mocks-server-example", "some-value"); | ||
core.logger.info("Custom header added by route variant middleware"); | ||
next(); | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: "disabled", // variant id | ||
disabled: true, | ||
}, | ||
], | ||
}, | ||
]; |
Oops, something went wrong.