mockaton 8.2.2 → 8.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.idea/dictionaries/efortis.xml +0 -3
- package/.idea/encodings.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -105
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/jsLinters/eslint.xml +0 -6
- package/.idea/misc.xml +0 -115
- package/.idea/mockaton.iml +0 -8
- package/.idea/modules.xml +0 -8
- package/.idea/shelf/custom_methods,_but_nodejs_does_not_support_them_https___github_com_nodejs_llhttp_pull_54/shelved.patch +0 -260
- package/.idea/shelf/custom_methods__but_nodejs_does_not_support_them_https___github_com_nodejs_llhttp_pull_54.xml +0 -4
- package/.idea/shelf/preflight/shelved.patch +0 -122
- package/.idea/shelf/preflight.xml +0 -4
- package/.idea/shelf/preflight1/shelved.patch +0 -289
- package/.idea/shelf/preflight1.xml +0 -4
- package/.idea/shelf/ts/shelved.patch +0 -229
- package/.idea/shelf/ts.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/.idea/webResources.xml +0 -14
- package/.idea/workspace.xml +0 -248
package/package.json
CHANGED
package/.idea/encodings.xml
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
|
2
|
-
<profile version="1.0">
|
|
3
|
-
<option name="myName" value="Project Default" />
|
|
4
|
-
<inspection_tool class="AmdModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
5
|
-
<inspection_tool class="BadExpressionStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
6
|
-
<inspection_tool class="CallerJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
7
|
-
<inspection_tool class="CommaExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
8
|
-
<inspection_tool class="ConstantConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
9
|
-
<inspection_tool class="ConstantIfStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
10
|
-
<inspection_tool class="ContinueOrBreakFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
11
|
-
<inspection_tool class="DuplicateCaseLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
12
|
-
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
13
|
-
<inspection_tool class="ES6BindWithArrowFunction" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
14
|
-
<inspection_tool class="ES6ConvertRequireIntoImport" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
|
15
|
-
<inspection_tool class="ES6ConvertVarToLetConst" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
16
|
-
<inspection_tool class="ES6ModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
17
|
-
<inspection_tool class="EmptyStatementBodyJS" enabled="false" level="WARNING" enabled_by_default="false">
|
|
18
|
-
<option name="m_reportEmptyBlocks" value="false" />
|
|
19
|
-
</inspection_tool>
|
|
20
|
-
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
21
|
-
<inspection_tool class="ExceptionCaughtLocallyJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
22
|
-
<inspection_tool class="FallThroughInSwitchStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
23
|
-
<inspection_tool class="FlowJSConfig" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
24
|
-
<inspection_tool class="FlowJSFlagCommentPlacement" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
25
|
-
<inspection_tool class="HbEmptyBlock" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
26
|
-
<inspection_tool class="IncompatibleMaskJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
27
|
-
<inspection_tool class="InfiniteLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
28
|
-
<inspection_tool class="InfiniteRecursionJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
29
|
-
<inspection_tool class="JSAccessibilityCheck" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
30
|
-
<inspection_tool class="JSAnnotator" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
31
|
-
<inspection_tool class="JSBitwiseOperatorUsage" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
32
|
-
<inspection_tool class="JSCheckFunctionSignatures" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
33
|
-
<inspection_tool class="JSClosureCompilerSyntax" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
34
|
-
<inspection_tool class="JSCommentMatchesSignature" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
35
|
-
<inspection_tool class="JSComparisonWithNaN" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
36
|
-
<inspection_tool class="JSConsecutiveCommasInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
37
|
-
<inspection_tool class="JSConstructorReturnsPrimitive" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
38
|
-
<inspection_tool class="JSDeprecatedSymbols" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
39
|
-
<inspection_tool class="JSDuplicatedDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
40
|
-
<inspection_tool class="JSFileReferences" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
41
|
-
<inspection_tool class="JSFunctionExpressionToArrowFunction" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
|
42
|
-
<inspection_tool class="JSJQueryEfficiency" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
43
|
-
<inspection_tool class="JSLastCommaInArrayLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
44
|
-
<inspection_tool class="JSLastCommaInObjectLiteral" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
45
|
-
<inspection_tool class="JSMethodCanBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
46
|
-
<inspection_tool class="JSMismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false">
|
|
47
|
-
<option name="queries" value="trace,write,forEach" />
|
|
48
|
-
<option name="updates" value="pop,push,shift,splice,unshift" />
|
|
49
|
-
</inspection_tool>
|
|
50
|
-
<inspection_tool class="JSNonASCIINames" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
51
|
-
<inspection_tool class="JSPotentiallyInvalidConstructorUsage" enabled="false" level="WARNING" enabled_by_default="false">
|
|
52
|
-
<option name="myConsiderUppercaseFunctionsToBeConstructors" value="true" />
|
|
53
|
-
</inspection_tool>
|
|
54
|
-
<inspection_tool class="JSPotentiallyInvalidTargetOfIndexedPropertyAccess" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
55
|
-
<inspection_tool class="JSPotentiallyInvalidUsageOfThis" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
56
|
-
<inspection_tool class="JSPrimitiveTypeWrapperUsage" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
57
|
-
<inspection_tool class="JSReferencingArgumentsOutsideOfFunction" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
58
|
-
<inspection_tool class="JSReferencingMutableVariableFromClosure" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
59
|
-
<inspection_tool class="JSStringConcatenationToES6Template" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
|
60
|
-
<inspection_tool class="JSSuspiciousNameCombination" enabled="false" level="WARNING" enabled_by_default="false">
|
|
61
|
-
<group names="x,width,left,right" />
|
|
62
|
-
<group names="y,height,top,bottom" />
|
|
63
|
-
<exclude classes="Math" />
|
|
64
|
-
</inspection_tool>
|
|
65
|
-
<inspection_tool class="JSTypeOfValues" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
66
|
-
<inspection_tool class="JSUndeclaredVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
67
|
-
<inspection_tool class="JSUndefinedPropertyAssignment" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
68
|
-
<inspection_tool class="JSUnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
69
|
-
<inspection_tool class="JSUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
70
|
-
<inspection_tool class="JSUnresolvedLibraryURL" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
71
|
-
<inspection_tool class="JSUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
72
|
-
<inspection_tool class="JSValidateJSDoc" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
73
|
-
<inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
74
|
-
<inspection_tool class="JSXNamespaceValidation" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
|
75
|
-
<inspection_tool class="LoopStatementThatDoesntLoopJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
76
|
-
<inspection_tool class="LossyEncoding" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
77
|
-
<inspection_tool class="MeteorUnresolvedSymbol" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
78
|
-
<inspection_tool class="NodeJsCodingAssistanceForCoreModules" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
79
|
-
<inspection_tool class="NodeModulesDependencies" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
80
|
-
<inspection_tool class="NpmUsedModulesInstalled" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
81
|
-
<inspection_tool class="OctalIntegerJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
82
|
-
<inspection_tool class="PointlessArithmeticExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
83
|
-
<inspection_tool class="PointlessBooleanExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
84
|
-
<inspection_tool class="ReservedWordUsedAsNameJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
85
|
-
<inspection_tool class="ReturnFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
86
|
-
<inspection_tool class="ShiftOutOfRangeJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
87
|
-
<inspection_tool class="SillyAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
88
|
-
<inspection_tool class="ThisExpressionReferencesGlobalObjectJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
89
|
-
<inspection_tool class="ThrowFromFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
90
|
-
<inspection_tool class="TrivialConditionalJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
91
|
-
<inspection_tool class="TrivialIfJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
92
|
-
<inspection_tool class="TsLint" enabled="true" level="ERROR" enabled_by_default="true" />
|
|
93
|
-
<inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
94
|
-
<inspection_tool class="UnnecessaryLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
95
|
-
<inspection_tool class="UnnecessaryLabelOnBreakStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
96
|
-
<inspection_tool class="UnnecessaryLabelOnContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
97
|
-
<inspection_tool class="UnnecessaryLocalVariableJS" enabled="false" level="WARNING" enabled_by_default="false">
|
|
98
|
-
<option name="m_ignoreImmediatelyReturnedVariables" value="false" />
|
|
99
|
-
<option name="m_ignoreAnnotatedVariables" value="false" />
|
|
100
|
-
</inspection_tool>
|
|
101
|
-
<inspection_tool class="UnnecessaryReturnJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
102
|
-
<inspection_tool class="UnreachableCodeJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
103
|
-
<inspection_tool class="WithStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
104
|
-
</profile>
|
|
105
|
-
</component>
|
package/.idea/misc.xml
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="JavaScriptSettings">
|
|
4
|
-
<option name="languageLevel" value="ES6" />
|
|
5
|
-
</component>
|
|
6
|
-
<component name="MarkdownProjectSettings" wasCopied="true">
|
|
7
|
-
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
|
|
8
|
-
<PanelProvider>
|
|
9
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
|
10
|
-
</PanelProvider>
|
|
11
|
-
</PreviewSettings>
|
|
12
|
-
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
|
|
13
|
-
<PegdownExtensions>
|
|
14
|
-
<option name="ABBREVIATIONS" value="false" />
|
|
15
|
-
<option name="ANCHORLINKS" value="true" />
|
|
16
|
-
<option name="ASIDE" value="false" />
|
|
17
|
-
<option name="ATXHEADERSPACE" value="true" />
|
|
18
|
-
<option name="AUTOLINKS" value="true" />
|
|
19
|
-
<option name="DEFINITIONS" value="false" />
|
|
20
|
-
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
|
21
|
-
<option name="FENCED_CODE_BLOCKS" value="true" />
|
|
22
|
-
<option name="FOOTNOTES" value="false" />
|
|
23
|
-
<option name="HARDWRAPS" value="false" />
|
|
24
|
-
<option name="HTML_DEEP_PARSER" value="false" />
|
|
25
|
-
<option name="INSERTED" value="false" />
|
|
26
|
-
<option name="QUOTES" value="false" />
|
|
27
|
-
<option name="RELAXEDHRULES" value="true" />
|
|
28
|
-
<option name="SMARTS" value="false" />
|
|
29
|
-
<option name="STRIKETHROUGH" value="true" />
|
|
30
|
-
<option name="SUBSCRIPT" value="false" />
|
|
31
|
-
<option name="SUPERSCRIPT" value="false" />
|
|
32
|
-
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
|
33
|
-
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
|
34
|
-
<option name="TABLES" value="true" />
|
|
35
|
-
<option name="TASKLISTITEMS" value="true" />
|
|
36
|
-
<option name="TOC" value="false" />
|
|
37
|
-
<option name="WIKILINKS" value="true" />
|
|
38
|
-
</PegdownExtensions>
|
|
39
|
-
<ParserOptions>
|
|
40
|
-
<option name="ADMONITION_EXT" value="false" />
|
|
41
|
-
<option name="ATTRIBUTES_EXT" value="false" />
|
|
42
|
-
<option name="COMMONMARK_LISTS" value="true" />
|
|
43
|
-
<option name="DUMMY" value="false" />
|
|
44
|
-
<option name="EMOJI_SHORTCUTS" value="true" />
|
|
45
|
-
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
|
|
46
|
-
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
|
47
|
-
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
|
48
|
-
<option name="GFM_TABLE_RENDERING" value="true" />
|
|
49
|
-
<option name="GITBOOK_URL_ENCODING" value="false" />
|
|
50
|
-
<option name="GITHUB_LISTS" value="false" />
|
|
51
|
-
<option name="GITHUB_WIKI_LINKS" value="true" />
|
|
52
|
-
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
|
|
53
|
-
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
|
54
|
-
<option name="NO_TEXT_ATTRIBUTES" value="false" />
|
|
55
|
-
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
|
|
56
|
-
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
|
57
|
-
</ParserOptions>
|
|
58
|
-
</ParserSettings>
|
|
59
|
-
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false">
|
|
60
|
-
<GeneratorProvider>
|
|
61
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
|
62
|
-
</GeneratorProvider>
|
|
63
|
-
<headerTop />
|
|
64
|
-
<headerBottom />
|
|
65
|
-
<bodyTop />
|
|
66
|
-
<bodyBottom />
|
|
67
|
-
</HtmlSettings>
|
|
68
|
-
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
|
|
69
|
-
<StylesheetProvider>
|
|
70
|
-
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
|
71
|
-
</StylesheetProvider>
|
|
72
|
-
<ScriptProviders />
|
|
73
|
-
<cssText />
|
|
74
|
-
<cssUriHistory />
|
|
75
|
-
</CssSettings>
|
|
76
|
-
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
|
77
|
-
<LinkMapSettings>
|
|
78
|
-
<textMaps />
|
|
79
|
-
</LinkMapSettings>
|
|
80
|
-
</component>
|
|
81
|
-
<component name="ProjectInspectionProfilesVisibleTreeState">
|
|
82
|
-
<entry key="Project Default">
|
|
83
|
-
<profile-state>
|
|
84
|
-
<expanded-state>
|
|
85
|
-
<State>
|
|
86
|
-
<id />
|
|
87
|
-
</State>
|
|
88
|
-
<State>
|
|
89
|
-
<id>Data flow issuesJavaScript</id>
|
|
90
|
-
</State>
|
|
91
|
-
<State>
|
|
92
|
-
<id>Error handlingJavaScript</id>
|
|
93
|
-
</State>
|
|
94
|
-
<State>
|
|
95
|
-
<id>JavaScript</id>
|
|
96
|
-
</State>
|
|
97
|
-
<State>
|
|
98
|
-
<id>JavaScript validity issuesJavaScript</id>
|
|
99
|
-
</State>
|
|
100
|
-
</expanded-state>
|
|
101
|
-
<selected-state>
|
|
102
|
-
<State>
|
|
103
|
-
<id>BashSupport</id>
|
|
104
|
-
</State>
|
|
105
|
-
</selected-state>
|
|
106
|
-
</profile-state>
|
|
107
|
-
</entry>
|
|
108
|
-
</component>
|
|
109
|
-
<component name="TypeScriptCompiler">
|
|
110
|
-
<option name="useService" value="false" />
|
|
111
|
-
</component>
|
|
112
|
-
<component name="YarnPnpManager">
|
|
113
|
-
<pnp-files />
|
|
114
|
-
</component>
|
|
115
|
-
</project>
|
package/.idea/mockaton.iml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$" />
|
|
5
|
-
<orderEntry type="inheritedJdk" />
|
|
6
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
-
</component>
|
|
8
|
-
</module>
|
package/.idea/modules.xml
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
Index: README.md
|
|
2
|
-
IDEA additional info:
|
|
3
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
4
|
-
<+><img src=\"src/mockaton-logo.svg\" alt=\"Mockaton Logo\" width=\"210\" style=\"margin-top: 30px\"/>\n\n_Mockaton_ is a mock server for developing and testing frontends.\n\nIt scans a given directory for files following a specific\nfile name convention, which is similar to the URL paths. For\nexample, the following file will be served for `/api/user/1234`\n```\nmy-mocks-dir/api/user/[user-id].GET.200.json\n```\n\n[This browser extension](https://github.com/ericfortis/devtools-ext-tar-http-requests)\ncan be used for downloading a TAR of your XHR requests following that convention.\n\n## What for?\n- Avoids having to spin up and maintain hefty or complex backends when developing UIs.\n- For a deterministic and comprehensive backend state. For example, having all the possible\n state variants of a particular collection helps for spotting inadvertent bugs. And having those\n assorted responses are not easy to trigger from the backend.\n- Testing empty responses.\n- Testing spinners by delaying responses.\n- Testing errors such as _Bad Request_ and _Internal Server Error_.\n- Triggering notifications and alerts.\n- Prototyping before the backend API is developed.\n- Setting up tests.\n- If you commit the mocks in the repo, when bisecting a bug, you don’t\n have to sync the frontend with many backend repos.\n - Similarly, I can check out long-lived branches that have old API contracts.\n- As API documentation.\n\n## Alternatives\n- Chrome DevTools allows for [overriding responses](https://developer.chrome.com/docs/devtools/overrides)\n- Reverse Proxies such as [Burp](https://portswigger.net/burp) are also handy for overriding responses.\n- Storybook’s [MSW](https://storybook.js.org/addons/msw-storybook-addon)\n\n### Caveats\n- Syncing the mocks, but the browser extension mentioned above helps.\n\n\n## Getting Started\nThe best way to learn _Mockaton_ is by checking out this repo and\nexploring its [sample-mocks/](./sample-mocks) directory. Then, run\n[`./_usage_example.js`](./_usage_example.js) and you’ll see the dashboard.\n\nYou can select mock files without resetting Mockaton. The _Reset_\nbutton is for when you add, remove, or rename a mock file.\n\nThe dropdown lets you pick a mock variant, details in the next section. Next to it is a\n_Delay_ toggler, and a button for sending _500 - Internal Server Error_ on that endpoint.\n\n<img src=\"./README-dashboard.png\" style=\"max-width:820px\"/>\n\n## Basic Usage\n```\nnpm install mockaton\n```\nCreate a `my-mockaton.js` file\n```js\nimport { resolve } from 'node:path'\nimport { Mockaton } from 'mockaton'\n\n\nMockaton({\n mocksDir: resolve('my-mocks-dir'),\n port: 2345\n})\n```\n\n```sh\nnode my-mockaton.js\n```\n\n## Config Options\n```ts\ninterface Config {\n mocksDir: string\n ignore?: RegExp // Defaults to /(\\.DS_Store|~)$/\n\n staticDir?: string // These files don’t use the mock-filename convention\n\n host?: string, // Defaults to 'localhost'\n port?: number // Defaults to 0, which means auto-assigned\n proxyFallback?: string // e.g. http://localhost:9999 Target for relaying routes without mocks\n\n delay?: number // Defaults to 1200 (ms)\n cookies?: { [label: string]: string }\n extraMimes?: { [fileExt: string]: string }\n extraHeaders?: []\n\n onReady?: (dashboardUrl: string) => void // Defaults to trying to open macOS and Win default browser.\n}\n```\nThere’s a Config section below with more details.\n\n---\n\n## Mock Variants\nEach route can have many mocks, which could either be:\n- Different response __status code__. For example, for testing error responses.\n- __Comment__ on the filename, which is anything within parentheses.\n - e.g. `api/user(my-comment).POST.201.json`\n\nThose alternatives can be manually selected in the dashboard\nUI, or programmatically, for instance, for setting up tests.\n\n### Default Mock for a Route\nYou can add the comment: `(default)` to a filename.\nOtherwise, the first file in **alphabetical order** wins.\n\n```\napi/user(default).GET.200.json\n```\n\n---\n\n## You can write JSON mocks in JavaScript\nAn Object, Array, or String is sent as JSON.\n\n`api/foo.GET.200.js`\n```js\nexport default [\n { id: 0 }\n]\n```\n\nOr, export default a function. In it, you can override the\nresponse status and the default JSON content type. But don’t call\n`response.end()`, just return a `string`, `Buffer`, or `Uint8Array`.\n\nThink of this as an HTTP handler. You can read or write to a\ndatabase, or pull data from a backend. The `request` is of type\n[IncomingMessage](https://nodejs.org/api/http.html#class-httpincomingmessage), and the\n`response` a [ServerResponse](https://nodejs.org/api/http.html#class-httpserverresponse).\n```js\nexport default function optionalName(request, response) {\n globalThis.myDatabase ??= { count: 0 }\n globalThis.myDatabase.count++\n\n return JSON.stringify({ a: 1 })\n}\n```\n\n\n## File Name Convention\n\n\n### Extension\n`.Method.ResponseStatusCode.FileExt`\n\n\n### Dynamic Parameters\nAnything within square brackets. For example:\n<pre>\napi/user/<b>[id]</b>/<b>[age]</b>.GET.200.json\n</pre>\n\n### Comments\nComments are anything within parentheses, including them.\nThey are ignored for URL purposes, so they have no effect\non the URL mask. For example, these two are for `/api/foo`\n<pre>\napi/foo<b>(my comment)</b>.GET.200.json\napi/foo.GET.200.json\n</pre>\n\n### Query String Params\n<pre>\napi/video<b>?limit=[limit]</b>.GET.200.json\n</pre>\n\nThe query string is ignored when routing to it. In other words, it’s\nonly used for documenting the URL contract.\n\nSpeaking of which, in Windows, filenames containing \"?\" are [not\npermitted](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file),\nbut since that’s part of the query string, it’s ignored anyway.\n\n\n### Index-like route\nFor instance, let's say you have `api/foo/bar`, and\n`api/foo`. For the latter you have two options:\n\n**Option A.** Place it outside the directory:\n```\napi/foo/\napi/foo.GET.200.json\n```\n\n**Option B.** Omit the filename:\n```text\napi/foo/.GET.200.json\n```\n\n---\n\n\n## `Config.proxyFallback`\nLets you specify a target server for serving routes you don’t have mocks for.\n\n\n## `Config.delay` \uD83D\uDD53\nThe clock icon next to the mock selector is a checkbox for delaying a\nparticular response. They are handy for testing spinners.\n\nThe delay is globally configurable via `Config.delay = 1200` (milliseconds).\n\n\n## `Config.staticDir`\nThese files don’t use the mock filename convention. They take precedence\nover mocks. Also, they get served on the same address, so no CORS issues.\n\nUse Case 1: If you have a bunch of static assets you don’t want to add `.GET.200.ext`\n\nUse Case 2: For a standalone demo server. For example,\nbuild your frontend bundle, and serve it from Mockaton.\n\n\n## `Config.cookies`\nThe selected cookie is sent in every response in the `Set-Cookie` header.\n\nThe key is just a label used for selecting a particular cookie in the\ndashboard. In the dashboard, only one cookie can be selected. If you need\nmore cookies you can inject additional cookies globally in `Config.extraHeaders`.\n\n`jwtCookie` has a hardcoded header and signature. In other\nwords, it’s useful if you only care about its payload.\n\n```js\nimport { jwtCookie } from 'mockaton'\n\n\nConfig.cookies = {\n 'My Admin User': 'my-cookie=1;Path=/;SameSite=strict',\n 'My Normal User': 'my-cookie=0;Path=/;SameSite=strict',\n 'My JWT': jwtCookie('my-cookie', {\n email: 'john.doe@example.com',\n picture: 'https://cdn.auth0.com/avatars/jd.png'\n })\n}\n```\n\n## `Config.extraHeaders`\nThey are applied last, right before ending the response.\nIn other words, they can overwrite the `Content-Type`. Note\nthat it's an array and the header name goes in even indices.\n\n```js\nConfig.extraHeaders = [\n 'Server', 'Mockaton',\n 'Set-Cookie', 'foo=FOO;Path=/;SameSite=strict',\n 'Set-Cookie', 'bar=BAR;Path=/;SameSite=strict'\n]\n```\n\n## `Config.extraMimes`\n```js\nConfig.extraMimes = {\n jpg: 'application/jpeg'\n}\n```\n\n## `Config.onReady`\nThis is a callback `(dashboardAddress: string) => void`, which defaults to\ntrying to open the dashboard in your default browser in macOS and Windows.\n\nIf you don’t want to open a browser, pass a noop, such as\n```js\nConfig.onReady = () => {}\n```\n\nOn Linux, you could pass:\n```js\nimport { exec } from 'node:child_process'\n\n\nConfig.onReady = function openInBrowser(address) {\n exec(`xdg-open ${address}`)\n}\n```\n\nOr, for more cross-platform utility, you could `npm install open` and pass it.\n```js\nimport open from 'open'\n\n\nConfig.onReady = open\n```\n\n---\n\n## HTTP API\n`Commander` is a wrapper for the Mockaton HTTP API.\nAll of its methods return their `fetch` response promise.\n```js\nimport { Commander } from 'mockaton'\n\n\nconst myMockatonAddr = 'http://localhost:2345'\nconst mockaton = new Commander(myMockatonAddr)\n```\n\n### Select a mock file for a route\n```js\nawait mockaton.select('api/foo.200.GET.json')\n```\n### Select all mocks that have a particular comment\n```js\nawait mockaton.bulkSelectByComment('(demo-a)')\n```\n\n### Set Route is Delayed Flag\n```js\nawait mockaton.setRouteIsDelayed('GET', '/api/foo', true)\n```\n\n### Select a cookie\nIn `Config.cookies`, each key is the label used for selecting it.\n```js\nawait mockaton.selectCookie('My Normal User')\n```\n\n### Set Fallback Proxy\n```js\nawait mockaton.setProxyFallback('http://example.com')\n```\nPass an empty string to disable it.\n\n### Reset\nRe-initialize the collection. So if you added or removed mocks they\nwill be considered. The selected mocks, cookies, and delays go\nback to default, but `Config.proxyFallback` is not affected.\n```js\nawait mockaton.reset()\n```\n\n\n## TODO\n- Refactor Tests\n- Dashboard. List `staticDir` and indicate if it’s overriding some mock.\n
|
|
5
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
6
|
-
<+>UTF-8
|
|
7
|
-
===================================================================
|
|
8
|
-
diff --git a/README.md b/README.md
|
|
9
|
-
--- a/README.md (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
10
|
-
+++ b/README.md (date 1727486643274)
|
|
11
|
-
@@ -85,7 +85,9 @@
|
|
12
|
-
delay?: number // Defaults to 1200 (ms)
|
|
13
|
-
cookies?: { [label: string]: string }
|
|
14
|
-
extraMimes?: { [fileExt: string]: string }
|
|
15
|
-
+
|
|
16
|
-
extraHeaders?: []
|
|
17
|
-
+ customMethods?: string[]
|
|
18
|
-
|
|
19
|
-
onReady?: (dashboardUrl: string) => void // Defaults to trying to open macOS and Win default browser.
|
|
20
|
-
}
|
|
21
|
-
@@ -259,6 +261,15 @@
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
+## `Config.customMethods`
|
|
26
|
-
+By default, only the standard HTTP request methods are supported:
|
|
27
|
-
+
|
|
28
|
-
+GET, HEAD, OPTIONS, TRACE, PUT, DELETE, POST, PATCH, CONNECT
|
|
29
|
-
+```js
|
|
30
|
-
+Config.customMethods = ['EDIT', 'COPY', 'LOCK']
|
|
31
|
-
+```
|
|
32
|
-
+
|
|
33
|
-
+
|
|
34
|
-
## `Config.onReady`
|
|
35
|
-
This is a callback `(dashboardAddress: string) => void`, which defaults to
|
|
36
|
-
trying to open the dashboard in your default browser in macOS and Windows.
|
|
37
|
-
Index: index.d.ts
|
|
38
|
-
IDEA additional info:
|
|
39
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
40
|
-
<+>import { Server } from 'node:http';\n\ninterface Config {\n\tmocksDir: string\n\tignore?: RegExp\n\n\tstaticDir?: string\n\n\thost?: string,\n\tport?: number\n\tproxyFallback?: string\n\n\tdelay?: number\n\tcookies?: { [label: string]: string }\n\textraHeaders?: [string, string][]\n\textraMimes?: { [fileExt: string]: string }\n\n\tonReady?: (address: string) => void\n}\n\n\nexport function Mockaton(options: Config): Server\n\n\nexport function jwtCookie(cookieName: string, payload: any): string\n\n\nexport class Commander {\n\tconstructor(addr: string)\n\n\tselect(file: string): Promise<Response>\n\n\tbulkSelectByComment(comment: string): Promise<Response>\n\n\tsetRouteIsDelayed(routeMethod: string, routeUrlMask: string, delayed: boolean): Promise<Response>\n\n\tselectCookie(cookieKey: string): Promise<Response>\n\n\tsetProxyFallback(proxyAddr: string): Promise<Response>\n\n\treset(): Promise<Response>\n\n\tlistCookies(): Promise<Response>\n\n\tlistComments(): Promise<Response>\n}\n
|
|
41
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
42
|
-
<+>UTF-8
|
|
43
|
-
===================================================================
|
|
44
|
-
diff --git a/index.d.ts b/index.d.ts
|
|
45
|
-
--- a/index.d.ts (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
46
|
-
+++ b/index.d.ts (date 1727485857831)
|
|
47
|
-
@@ -13,7 +13,9 @@
|
|
48
|
-
delay?: number
|
|
49
|
-
cookies?: { [label: string]: string }
|
|
50
|
-
extraHeaders?: [string, string][]
|
|
51
|
-
+
|
|
52
|
-
extraMimes?: { [fileExt: string]: string }
|
|
53
|
-
+ customMethods?: string[]
|
|
54
|
-
|
|
55
|
-
onReady?: (address: string) => void
|
|
56
|
-
}
|
|
57
|
-
Index: _usage_example.js
|
|
58
|
-
IDEA additional info:
|
|
59
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
60
|
-
<+>#!/usr/bin/env node\n\nimport { join } from 'node:path'\nimport { Mockaton, jwtCookie } from './index.js' // from 'mockaton'\n\nMockaton({\n\tport: 2345,\n\tmocksDir: join(import.meta.dirname, 'sample-mocks'),\n\tstaticDir: join(import.meta.dirname, 'sample-static'),\n\tcookies: {\n\t\t'My Admin User': 'my-cookie=1;Path=/;SameSite=strict',\n\t\t'My Normal User': 'my-cookie=0;Path=/;SameSite=strict',\n\t\t'My JWT': jwtCookie('my-cookie', {\n\t\t\temail: 'john.doe@example.com',\n\t\t\tpicture: 'https://cdn.auth0.com/avatars/jd.png'\n\t\t})\n\t}\n})\n
|
|
61
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
62
|
-
<+>UTF-8
|
|
63
|
-
===================================================================
|
|
64
|
-
diff --git a/_usage_example.js b/_usage_example.js
|
|
65
|
-
--- a/_usage_example.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
66
|
-
+++ b/_usage_example.js (date 1727487282650)
|
|
67
|
-
@@ -14,5 +14,6 @@
|
|
68
|
-
email: 'john.doe@example.com',
|
|
69
|
-
picture: 'https://cdn.auth0.com/avatars/jd.png'
|
|
70
|
-
})
|
|
71
|
-
- }
|
|
72
|
-
+ },
|
|
73
|
-
+ customMethods: ['COPY']
|
|
74
|
-
})
|
|
75
|
-
Index: src/Filename.js
|
|
76
|
-
IDEA additional info:
|
|
77
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
78
|
-
<+>const httpMethods = [\n\t'CONNECT', 'DELETE', 'GET',\n\t'HEAD', 'OPTIONS', 'PATCH',\n\t'POST', 'PUT', 'TRACE'\n]\n\nconst reComments = /\\(.*?\\)/g // Anything within parentheses\n\nexport const extractComments = filename =>\n\tArray.from(filename.matchAll(reComments), ([comment]) => comment)\n\nexport const includesComment = (filename, search) =>\n\textractComments(filename).some(comment => comment.includes(search))\n\n\nexport function filenameIsValid(file) {\n\tconst error = validateFilename(file)\n\tif (error)\n\t\tconsole.error(error, file)\n\treturn !error\n}\nfunction validateFilename(file) {\n\tconst tokens = file.replace(reComments, '').split('.')\n\tif (tokens.length < 4)\n\t\treturn 'Invalid Filename Convention'\n\tconst { status, method } = parseFilename(file)\n\tif (!responseStatusIsValid(status))\n\t\treturn `Invalid HTTP Response Status: \"${status}\"`\n\tif (!httpMethods.includes(method))\n\t\treturn `Unrecognized HTTP Method: \"${method}\"`\n}\n\n\nexport function parseFilename(file) {\n\tconst tokens = file.replace(reComments, '').split('.')\n\treturn {\n\t\turlMask: '/' + removeTrailingSlash(tokens.slice(0, -3).join('.')),\n\t\tmethod: tokens.at(-3),\n\t\tstatus: Number(tokens.at(-2))\n\t}\n}\n\n\nfunction removeTrailingSlash(url = '') {\n\treturn url\n\t\t.replace(/\\/$/, '')\n\t\t.replace('/?', '?')\n\t\t.replace('/#', '#')\n}\n\nfunction responseStatusIsValid(status) {\n\treturn Number.isInteger(status)\n\t\t&& status >= 100\n\t\t&& status <= 599\n}\n\n\n\n\n
|
|
79
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
80
|
-
<+>UTF-8
|
|
81
|
-
===================================================================
|
|
82
|
-
diff --git a/src/Filename.js b/src/Filename.js
|
|
83
|
-
--- a/src/Filename.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
84
|
-
+++ b/src/Filename.js (date 1727486499387)
|
|
85
|
-
@@ -1,7 +1,7 @@
|
|
86
|
-
const httpMethods = [
|
|
87
|
-
- 'CONNECT', 'DELETE', 'GET',
|
|
88
|
-
- 'HEAD', 'OPTIONS', 'PATCH',
|
|
89
|
-
- 'POST', 'PUT', 'TRACE'
|
|
90
|
-
+ 'GET', 'HEAD', 'OPTIONS', 'TRACE',
|
|
91
|
-
+ 'PUT', 'DELETE', 'POST', 'PATCH',
|
|
92
|
-
+ 'CONNECT'
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
const reComments = /\(.*?\)/g // Anything within parentheses
|
|
96
|
-
@@ -13,20 +13,22 @@
|
|
97
|
-
extractComments(filename).some(comment => comment.includes(search))
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-export function filenameIsValid(file) {
|
|
101
|
-
- const error = validateFilename(file)
|
|
102
|
-
+export function filenameIsValid(file, customMethods) {
|
|
103
|
-
+ const error = validateFilename(file, customMethods)
|
|
104
|
-
if (error)
|
|
105
|
-
console.error(error, file)
|
|
106
|
-
return !error
|
|
107
|
-
}
|
|
108
|
-
-function validateFilename(file) {
|
|
109
|
-
+function validateFilename(file, customMethods) {
|
|
110
|
-
const tokens = file.replace(reComments, '').split('.')
|
|
111
|
-
if (tokens.length < 4)
|
|
112
|
-
return 'Invalid Filename Convention'
|
|
113
|
-
+
|
|
114
|
-
const { status, method } = parseFilename(file)
|
|
115
|
-
if (!responseStatusIsValid(status))
|
|
116
|
-
return `Invalid HTTP Response Status: "${status}"`
|
|
117
|
-
- if (!httpMethods.includes(method))
|
|
118
|
-
+
|
|
119
|
-
+ if (!httpMethods.includes(method) && !customMethods.includes(method))
|
|
120
|
-
return `Unrecognized HTTP Method: "${method}"`
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
Index: src/MockDispatcher.js
|
|
124
|
-
IDEA additional info:
|
|
125
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
126
|
-
<+>import { join } from 'node:path'\nimport { readFileSync as read } from 'node:fs'\n\nimport { proxy } from './ProxyRelay.js'\nimport { cookie } from './cookie.js'\nimport { Config } from './Config.js'\nimport { mimeFor } from './utils/mime.js'\nimport * as mockBrokerCollection from './mockBrokersCollection.js'\nimport { JsonBodyParserError } from './utils/http-request.js'\nimport { sendInternalServerError, sendNotFound, sendBadRequest } from './utils/http-response.js'\n\n\nexport async function dispatchMock(req, response) {\n\ttry {\n\t\tconst broker = mockBrokerCollection.getBrokerForUrl(req.method, req.url)\n\t\tif (!broker) {\n\t\t\tif (Config.proxyFallback)\n\t\t\t\tawait proxy(req, response)\n\t\t\telse\n\t\t\t\tsendNotFound(response)\n\t\t\treturn\n\t\t}\n\n\t\tconst { file, status, delay } = broker\n\t\tconsole.log(decodeURIComponent(req.url), ' → ', file)\n\t\tconst filePath = join(Config.mocksDir, file)\n\n\t\tlet mockBody\n\t\tif (file.endsWith('.js')) {\n\t\t\tresponse.setHeader('Content-Type', mimeFor('.json'))\n\t\t\tconst jsExport = (await import(filePath + '?' + Date.now())).default // date for cache busting\n\t\t\tmockBody = typeof jsExport === 'function'\n\t\t\t\t? await jsExport(req, response)\n\t\t\t\t: JSON.stringify(jsExport, null, 2)\n\t\t}\n\t\telse {\n\t\t\tresponse.setHeader('Content-Type', mimeFor(file))\n\t\t\tmockBody = broker.isTemp500\n\t\t\t\t? ''\n\t\t\t\t: read(filePath)\n\t\t}\n\n\t\tif (cookie.getCurrent())\n\t\t\tresponse.setHeader('Set-Cookie', cookie.getCurrent())\n\n\t\tresponse.writeHead(status, Config.extraHeaders)\n\t\tsetTimeout(() => response.end(mockBody), delay)\n\t}\n\tcatch (error) {\n\t\tif (error instanceof JsonBodyParserError)\n\t\t\tsendBadRequest(response, error)\n\t\telse if (error.code === 'ENOENT')\n\t\t\tsendNotFound(response) // file has been deleted\n\t\telse\n\t\t\tsendInternalServerError(response, error)\n\t}\n}\n
|
|
127
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
128
|
-
<+>UTF-8
|
|
129
|
-
===================================================================
|
|
130
|
-
diff --git a/src/MockDispatcher.js b/src/MockDispatcher.js
|
|
131
|
-
--- a/src/MockDispatcher.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
132
|
-
+++ b/src/MockDispatcher.js (date 1727487623923)
|
|
133
|
-
@@ -47,8 +47,11 @@
|
|
134
|
-
setTimeout(() => response.end(mockBody), delay)
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
- if (error instanceof JsonBodyParserError)
|
|
138
|
-
+ if (error instanceof JsonBodyParserError) {
|
|
139
|
-
+
|
|
140
|
-
+ console.log('json error')
|
|
141
|
-
sendBadRequest(response, error)
|
|
142
|
-
+ }
|
|
143
|
-
else if (error.code === 'ENOENT')
|
|
144
|
-
sendNotFound(response) // file has been deleted
|
|
145
|
-
else
|
|
146
|
-
Index: sample-mocks/api/custom.COPY.200.json
|
|
147
|
-
IDEA additional info:
|
|
148
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
149
|
-
<+>UTF-8
|
|
150
|
-
===================================================================
|
|
151
|
-
diff --git a/sample-mocks/api/custom.COPY.200.json b/sample-mocks/api/custom.COPY.200.json
|
|
152
|
-
new file mode 100644
|
|
153
|
-
--- /dev/null (date 1727487243652)
|
|
154
|
-
+++ b/sample-mocks/api/custom.COPY.200.json (date 1727487243652)
|
|
155
|
-
@@ -0,0 +1,3 @@
|
|
156
|
-
+{
|
|
157
|
-
+ "foo": "bar"
|
|
158
|
-
+}
|
|
159
|
-
Index: src/mockBrokersCollection.js
|
|
160
|
-
IDEA additional info:
|
|
161
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
162
|
-
<+>import { Config } from './Config.js'\nimport { cookie } from './cookie.js'\nimport { MockBroker } from './MockBroker.js'\nimport { listFilesRecursively } from './utils/fs.js'\nimport { parseFilename, filenameIsValid } from './Filename.js'\n\n\n/**\n * @example\n * {\n * GET: {\n * /api/route-a: <MockBroker>\n * /api/route-b: <MockBroker>\n * },\n * POST: {…}\n * }\n */\nlet collection = {}\n\nexport function init() {\n\tcollection = {}\n\tcookie.init(Config.cookies)\n\n\tconst files = listFilesRecursively(Config.mocksDir)\n\t\t.sort()\n\t\t.filter(f => !Config.ignore.test(f) && filenameIsValid(f))\n\n\tfor (const file of files) {\n\t\tconst { method, urlMask } = parseFilename(file)\n\t\tcollection[method] ??= {}\n\t\tif (!collection[method][urlMask])\n\t\t\tcollection[method][urlMask] = new MockBroker(file)\n\t\telse\n\t\t\tcollection[method][urlMask].register(file)\n\t}\n\n\tforEachBroker(broker => {\n\t\tbroker.selectDefaultFile()\n\t\tbroker.ensureItHas500()\n\t})\n}\n\n\nexport const getAll = () => collection\n\nexport const getBrokerByFilename = file => {\n\tconst { method, urlMask } = parseFilename(file)\n\tif (collection[method])\n\t\treturn collection[method][urlMask]\n}\n\n// Searching the routes in reverse order so dynamic params (e.g.\n// /user/[id]) don’t take precedence over exact paths (e.g.\n// /user/name). That’s because \"[]\" chars are lower than alphanumeric ones.\n// BTW, `urlMasks` always start with \"/\", so there’s no need to\n// worry about the primacy of array-like keys when iterating.\nexport function getBrokerForUrl(method, url) {\n\tif (!collection[method])\n\t\treturn\n\tconst brokers = Object.values(collection[method])\n\tfor (let i = brokers.length - 1; i >= 0; i--)\n\t\tif (brokers[i].urlMaskMatches(url))\n\t\t\treturn brokers[i]\n}\n\nexport function extractAllComments() {\n\tconst comments = new Set()\n\tforEachBroker(broker => {\n\t\tfor (const c of broker.extractComments())\n\t\t\tcomments.add(c)\n\t})\n\treturn Array.from(comments)\n}\n\nexport function setMocksMatchingComment(comment) {\n\tforEachBroker(broker => broker.setByMatchingComment(comment))\n}\n\n\nfunction forEachBroker(fn) {\n\tfor (const brokers of Object.values(collection))\n\t\tObject.values(brokers).forEach(fn)\n}\n\n
|
|
163
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
164
|
-
<+>UTF-8
|
|
165
|
-
===================================================================
|
|
166
|
-
diff --git a/src/mockBrokersCollection.js b/src/mockBrokersCollection.js
|
|
167
|
-
--- a/src/mockBrokersCollection.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
168
|
-
+++ b/src/mockBrokersCollection.js (date 1727486032638)
|
|
169
|
-
@@ -23,7 +23,7 @@
|
|
170
|
-
|
|
171
|
-
const files = listFilesRecursively(Config.mocksDir)
|
|
172
|
-
.sort()
|
|
173
|
-
- .filter(f => !Config.ignore.test(f) && filenameIsValid(f))
|
|
174
|
-
+ .filter(f => !Config.ignore.test(f) && filenameIsValid(f, Config.customMethods))
|
|
175
|
-
|
|
176
|
-
for (const file of files) {
|
|
177
|
-
const { method, urlMask } = parseFilename(file)
|
|
178
|
-
Index: Tests.js
|
|
179
|
-
IDEA additional info:
|
|
180
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
181
|
-
<+>#!/usr/bin/env -S node --experimental-default-type=module\n\nimport { tmpdir } from 'node:os'\nimport { dirname } from 'node:path'\nimport { promisify } from 'node:util'\nimport { describe, it } from 'node:test'\nimport { createServer } from 'node:http'\nimport { equal, deepEqual, match } from 'node:assert/strict'\nimport { writeFileSync, mkdtempSync, mkdirSync } from 'node:fs'\n\nimport { Config } from './src/Config.js'\nimport { mimeFor } from './src/utils/mime.js'\nimport { Mockaton } from './src/Mockaton.js'\nimport { Commander } from './src/Commander.js'\nimport { parseFilename } from './src/Filename.js'\nimport { API, DEFAULT_500_COMMENT, DEFAULT_MOCK_COMMENT } from './src/ApiConstants.js'\n\n\nconst tmpDir = mkdtempSync(tmpdir()) + '/'\nconst staticTmpDir = mkdtempSync(tmpdir()) + '/'\nconsole.log(tmpDir)\n\nconst fixtureCustomMime = [\n\t'/api/custom-mime',\n\t'api/custom-mime.GET.200.my_custom_extension',\n\t'Custom Extension and MIME'\n]\n\nconst fixtureNonDefaultInName = [\n\t'/api/the-route',\n\t'api/the-route(default).GET.200.json',\n\t'default my route body content'\n]\nconst fixtureDefaultInName = [\n\t'/api/the-route',\n\t'api/the-route(default).GET.200.json',\n\t'default my route body content'\n]\n\nconst fixtureDelayed = [\n\t'/api/delayed',\n\t'api/delayed.GET.200.json',\n\t'Route_To_Be_Delayed'\n]\n\nconst fixtures = [\n\t[\n\t\t'/api',\n\t\t'api/.GET.200.json',\n\t\t'index-like route for /api, which could just be the extension convention'\n\t],\n\n\t// Exact route paths\n\tfixtureDefaultInName,\n\tfixtureDelayed,\n\t[\n\t\t'/api/the-route',\n\t\t'api/the-route(default).GET.200.json',\n\t\t'default my route body content'\n\t],\n\t[\n\t\t'/api/the-mime',\n\t\t'api/the-mime.GET.200.txt',\n\t\t'determines the content type'\n\t], [\n\t\t'/api/the-method-and-status',\n\t\t'api/the-method-and-status.POST.201.json',\n\t\t'obeys the HTTP method and response status'\n\t], [\n\t\t'/api/the-comment',\n\t\t'api/the-comment(this is the actual comment).GET.200(another comment).txt',\n\t\t''\n\t], [\n\t\t'/api/alternative',\n\t\t'api/alternative(comment-1).GET.200.json',\n\t\t'With_Comment_1'\n\t], [\n\t\t'/api/dot.in.path',\n\t\t'api/dot.in.path.GET.200.json',\n\t\t'Dot_in_Path'\n\t], [\n\t\t'/api/space & colon:',\n\t\t'api/space & colon:.GET.200.json',\n\t\t'Decodes URI'\n\t],\n\n\n\t// Dynamic Params\n\t[\n\t\t'/api/user/1234',\n\t\t'api/user/[id]/.GET.200.json',\n\t\t'variable at end'\n\t], [\n\t\t'/api/user/1234/suffix',\n\t\t'api/user/[id]/suffix.GET.200.json',\n\t\t'sandwich a variable that another route has at the end'\n\t], [\n\t\t'/api/user/exact-route',\n\t\t'api/user/exact-route.GET.200.json',\n\t\t'ensure dynamic params do not take precedence over exact routes'\n\t],\n\n\t// Query String\n\t[\n\t\t'/api/my-query-string?foo=[foo]&bar=[bar]',\n\t\t'api/my-query-string?foo=[foo]&bar=[bar].GET.200.json',\n\t\t'two query string params'\n\t], [\n\t\t'/api/company-a',\n\t\t'api/company-a/[id]?limit=[limit].GET.200.json',\n\t\t'without pretty-param nor query-params'\n\t], [\n\t\t'/api/company-b/',\n\t\t'api/company-b/[id]?limit=[limit].GET.200.json',\n\t\t'without pretty-param nor query-params with trailing slash'\n\t], [\n\t\t'/api/company-c/1234',\n\t\t'api/company-c/[id]?limit=[limit].GET.200.json',\n\t\t'with pretty-param and without query-params'\n\t], [\n\t\t'/api/company-d/1234/?',\n\t\t'api/company-d/[id]?limit=[limit].GET.200.json',\n\t\t'with pretty-param and without query-params, but with trailing slash and \"?\"'\n\t], [\n\t\t'/api/company-e/1234/?limit=4',\n\t\t'api/company-e/[id]?limit=[limit].GET.200.json',\n\t\t'with pretty-param and query-params'\n\t],\n\tfixtureCustomMime\n]\nfor (const [, file, body] of [fixtureNonDefaultInName, ...fixtures])\n\twrite(file, file.endsWith('.json') ? JSON.stringify(body) : body)\n\nwrite('api/.GET.500.txt', 'keeps non-autogenerated 500')\nwrite('api/alternative(comment-2).GET.200.json', JSON.stringify({ comment: 2 }))\nwrite('api/my-route(comment-2).GET.200.json', JSON.stringify({ comment: 2 }))\nwrite('api/ignored.GET.200.json~', '')\n\n// JavaScript to JSON\nwrite('/api/object.GET.200.js', 'export default { JSON_FROM_JS: true }')\n\nwriteStatic('index.html', '<h1>Static</h1>')\nwriteStatic('assets/app.js', 'const app = 1')\nwriteStatic('another-entry/index.html', '<h1>Another</h1>')\n\n\n\nconst server = Mockaton({\n\tmocksDir: tmpDir,\n\tstaticDir: staticTmpDir,\n\tdelay: 40,\n\tonReady: () => {},\n\tcookies: {\n\t\tuserA: 'CookieA',\n\t\tuserB: 'CookieB'\n\t},\n\textraHeaders: ['Server', 'MockatonTester'],\n\textraMimes: {\n\t\tmy_custom_extension: 'my_custom_mime'\n\t}\n})\nserver.on('listening', runTests)\n\nfunction mockatonAddr() {\n\tconst { address, port } = server.address()\n\treturn `http://${address}:${port}`\n}\n\nfunction request(path, options = {}) {\n\treturn fetch(`${mockatonAddr()}${path}`, options)\n}\n\nlet commander\nasync function runTests() {\n\tcommander = new Commander(mockatonAddr())\n\n\tawait testItRendersDashboard()\n\tawait test404()\n\n\tfor (const [url, file, body] of fixtures)\n\t\tawait testMockDispatching(url, file, body)\n\n\tawait testDefaultMock()\n\n\tawait testItUpdatesRouteDelay(...fixtureDelayed)\n\tawait testBadRequestWhenUpdatingNonExistingMockAlternative()\n\n\tawait testAutogenerates500(\n\t\t'/api/alternative',\n\t\t`api/alternative${DEFAULT_500_COMMENT}.GET.500.txt`)\n\n\tawait testPreservesExiting500(\n\t\t'/api',\n\t\t'api/.GET.500.txt',\n\t\t'keeps non-autogenerated 500')\n\n\tawait commander.reset()\n\tawait testItUpdatesTheCurrentSelectedMock(\n\t\t'/api/alternative',\n\t\t'api/alternative(comment-2).GET.200.json',\n\t\t200,\n\t\tJSON.stringify({ comment: 2 }))\n\n\tawait commander.reset()\n\tawait testExtractsAllComments([\n\t\t'(comment-1)',\n\t\t'(comment-2)',\n\t\tDEFAULT_500_COMMENT,\n\t\t'(this is the actual comment)',\n\t\t'(another comment)',\n\t\tDEFAULT_MOCK_COMMENT\n\t])\n\tawait testItBulkSelectsByComment('(comment-2)', [\n\t\t['/api/alternative', 'api/alternative(comment-2).GET.200.json', { comment: 2 }],\n\t\t['/api/my-route', 'api/my-route(comment-2).GET.200.json', { comment: 2 }]\n\t])\n\n\tawait commander.reset()\n\tfor (const [url, file, body] of fixtures)\n\t\tawait testMockDispatching(url, file, body)\n\n\tawait testMockDispatching('/api/object', 'api/object.GET.200.js', { JSON_FROM_JS: true }, mimeFor('.json'))\n\tawait testMockDispatching(...fixtureCustomMime, 'my_custom_mime')\n\tawait testJsFunctionMocks()\n\n\tawait testItUpdatesUserRole()\n\tawait testStaticFileServing()\n\tawait testInvalidFilenamesAreIgnored()\n\tawait testEnableFallbackSoRoutesWithoutMocksGetRelayed()\n\tserver.close()\n}\n\n\nasync function testItRendersDashboard() {\n\tconst res = await request(API.dashboard)\n\tconst body = await res.text()\n\tawait describe('Dashboard', () =>\n\t\tit('Renders HTML', () => match(body, new RegExp('<!DOCTYPE html>'))))\n}\n\nasync function test404() {\n\tawait it('Sends 404 when there is no mock', async () => {\n\t\tconst res = await request('/api/non-existing')\n\t\tequal(res.status, 404)\n\t})\n\tawait it('Sends 404 when there’s no mock at all for a method', async () => {\n\t\tconst res = await request('/api/non-existing-too', { method: 'DELETE' })\n\t\tequal(res.status, 404)\n\t})\n\tawait it('Ignores files ending in ~ by default, e.g. JetBrains temp files', async () => {\n\t\tconst res = await request('/api/ignored')\n\t\tequal(res.status, 404)\n\t})\n}\n\nasync function testMockDispatching(url, file, expectedBody, forcedMime = undefined) {\n\tconst { urlMask, method, status } = parseFilename(file)\n\tconst mime = forcedMime || mimeFor(file)\n\tconst res = await request(url, { method })\n\tconst body = mime === 'application/json'\n\t\t? await res.json()\n\t\t: await res.text()\n\tawait describe('URL Mask: ' + urlMask, () => {\n\t\tit('file: ' + file, () => deepEqual(body, expectedBody))\n\t\tit('mime: ' + mime, () => equal(res.headers.get('content-type'), mime))\n\t\tit('status: ' + status, () => equal(res.status, status))\n\t\tit('cookie: ' + mime, () => equal(res.headers.get('set-cookie'), 'CookieA'))\n\t\tit('extra header', () => equal(res.headers.get('server'), 'MockatonTester'))\n\t})\n}\n\nasync function testDefaultMock() {\n\tawait testMockDispatching(...fixtureDefaultInName)\n}\n\nasync function testItUpdatesTheCurrentSelectedMock(url, file, expectedStatus, expectedBody) {\n\tawait commander.select(file)\n\tconst res = await request(url)\n\tconst body = await res.text()\n\tawait describe('url: ' + url, () => {\n\t\tit('body is: ' + expectedBody, () => equal(body, expectedBody))\n\t\tit('status is: ' + expectedStatus, () => equal(res.status, expectedStatus))\n\t})\n}\n\nasync function testItUpdatesRouteDelay(url, file, expectedBody) {\n\tconst { method } = parseFilename(file)\n\tawait commander.setRouteIsDelayed(method, url, true)\n\tconst now = new Date()\n\tconst res = await request(url)\n\tconst body = await res.text()\n\tawait describe('url: ' + url, () => {\n\t\tit('body is: ' + expectedBody, () => equal(body, JSON.stringify(expectedBody)))\n\t\tit('delay', () => equal((new Date()).getTime() - now.getTime() > Config.delay, true))\n\t})\n}\n\nasync function testBadRequestWhenUpdatingNonExistingMockAlternative() {\n\tawait it('There are mocks for /api/the-route but not this one', async () => {\n\t\tconst missingFile = 'api/the-route(non-existing-variant).GET.200.json'\n\t\tconst res = await commander.select(missingFile)\n\t\tequal(res.status, 400)\n\t\tequal(await res.text(), `Missing Mock: ${missingFile}`)\n\t})\n}\n\nasync function testAutogenerates500(url, file) {\n\tawait commander.select(file)\n\tconst res = await request(url)\n\tconst body = await res.text()\n\tawait describe('autogenerated in-memory 500', () => {\n\t\tit('body is empty', () => equal(body, ''))\n\t\tit('status is: 500', () => equal(res.status, 500))\n\t})\n}\n\nasync function testPreservesExiting500(url, file, expectedBody) {\n\tawait commander.select(file)\n\tconst res = await request(url)\n\tconst body = await res.text()\n\tawait describe('preserves existing 500', () => {\n\t\tit('body is empty', () => equal(body, expectedBody))\n\t\tit('status is: 500', () => equal(res.status, 500))\n\t})\n}\n\nasync function testExtractsAllComments(expected) {\n\tconst res = await commander.listComments()\n\tconst body = await res.json()\n\tawait it('Extracts all comments without duplicates', () =>\n\t\tdeepEqual(body, expected))\n}\n\nasync function testItBulkSelectsByComment(comment, tests) {\n\tawait commander.bulkSelectByComment(comment)\n\tfor (const [url, file, body] of tests)\n\t\tawait testMockDispatching(url, file, body)\n}\n\n\nasync function testItUpdatesUserRole() {\n\tawait describe('Cookie', () => {\n\t\tit('Defaults to the first key:value', async () => {\n\t\t\tconst res = await commander.listCookies()\n\t\t\tdeepEqual(await res.json(), [\n\t\t\t\t['userA', true],\n\t\t\t\t['userB', false]\n\t\t\t])\n\t\t})\n\n\t\tit('Update the selected cookie', async () => {\n\t\t\tawait commander.selectCookie('userB')\n\t\t\tconst res = await commander.listCookies()\n\t\t\tdeepEqual(await res.json(), [\n\t\t\t\t['userA', false],\n\t\t\t\t['userB', true]\n\t\t\t])\n\t\t})\n\t})\n}\n\nasync function testJsFunctionMocks() {\n\tawait describe('JS Function Mocks', async () => {\n\t\twrite('api/js-func.POST.200.js', `\nexport default function (req, response) {\n response.setHeader('content-type', 'custom-mime')\n return 'SOME_STRING'\n}`)\n\t\tawait commander.reset() // for registering the file\n\t\tawait testMockDispatching('/api/js-func',\n\t\t\t'api/js-func.POST.200.js',\n\t\t\t'SOME_STRING',\n\t\t\t'custom-mime')\n\t})\n}\n\n\nasync function testStaticFileServing() {\n\tawait describe('Static File Serving', () => {\n\t\tit('Defaults to index.html', async () => {\n\t\t\tconst res = await request('/')\n\t\t\tconst body = await res.text()\n\t\t\tequal(body, '<h1>Static</h1>')\n\t\t\tequal(res.status, 200)\n\t\t})\n\n\t\tit('Defaults to in subdirs index.html', async () => {\n\t\t\tconst res = await request('/another-entry')\n\t\t\tconst body = await res.text()\n\t\t\tequal(body, '<h1>Another</h1>')\n\t\t\tequal(res.status, 200)\n\t\t})\n\n\t\tit('Serves exacts paths', async () => {\n\t\t\tconst res = await request('/assets/app.js')\n\t\t\tconst body = await res.text()\n\t\t\tequal(body, 'const app = 1')\n\t\t\tequal(res.status, 200)\n\t\t})\n\t})\n}\n\nasync function testInvalidFilenamesAreIgnored() {\n\tawait it('Invalid filenames get skipped, so they don’t crash the server', async (t) => {\n\t\tconst consoleErrorSpy = t.mock.method(console, 'error')\n\t\tconsoleErrorSpy.mock.mockImplementation(() => {}) // so they don’t render in the test report\n\n\t\twrite('api/_INVALID_FILENAME_CONVENTION_.json', '')\n\t\twrite('api/bad-filename-method._INVALID_METHOD_.200.json', '')\n\t\twrite('api/bad-filename-status.GET._INVALID_STATUS_.json', '')\n\t\tawait commander.reset()\n\t\tequal(consoleErrorSpy.mock.calls[0].arguments[0], 'Invalid Filename Convention')\n\t\tequal(consoleErrorSpy.mock.calls[1].arguments[0], 'Unrecognized HTTP Method: \"_INVALID_METHOD_\"')\n\t\tequal(consoleErrorSpy.mock.calls[2].arguments[0], 'Invalid HTTP Response Status: \"NaN\"')\n\t})\n}\n\nasync function testEnableFallbackSoRoutesWithoutMocksGetRelayed() {\n\tawait describe('Fallback', async () => {\n\t\tconst fallbackServer = createServer((_, response) => {\n\t\t\tresponse.setHeader('custom_header', 'my_custom_header')\n\t\t\tresponse.statusCode = 423\n\t\t\tresponse.end('From_Fallback_Server')\n\t\t})\n\t\tawait promisify(fallbackServer.listen).bind(fallbackServer, 0, '127.0.0.1')()\n\n\t\tawait commander.setProxyFallback(`http://localhost:${fallbackServer.address().port}`)\n\t\tawait it('Relays to fallback server', async () => {\n\t\t\tconst res = await request('/non-existing-mock')\n\t\t\tequal(res.headers.get('custom_header'), 'my_custom_header')\n\t\t\tequal(res.status, 423)\n\t\t\tequal(await res.text(), 'From_Fallback_Server')\n\t\t\tfallbackServer.close()\n\t\t})\n\t})\n}\n\n// Utils\n\nfunction write(filename, data) {\n\t_write(tmpDir + filename, data)\n}\n\nfunction writeStatic(filename, data) {\n\t_write(staticTmpDir + filename, data)\n}\n\nfunction _write(absPath, data) {\n\tmkdirSync(dirname(absPath), { recursive: true })\n\twriteFileSync(absPath, data, 'utf8')\n}\n\n
|
|
182
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
183
|
-
<+>UTF-8
|
|
184
|
-
===================================================================
|
|
185
|
-
diff --git a/Tests.js b/Tests.js
|
|
186
|
-
--- a/Tests.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
187
|
-
+++ b/Tests.js (date 1727487931436)
|
|
188
|
-
@@ -43,6 +43,12 @@
|
|
189
|
-
'Route_To_Be_Delayed'
|
|
190
|
-
]
|
|
191
|
-
|
|
192
|
-
+const fixtureCustomMethod = [
|
|
193
|
-
+ '/api/custom-method',
|
|
194
|
-
+ 'api/custom-method.FOO.200.json',
|
|
195
|
-
+ 'My_Custom_Method'
|
|
196
|
-
+]
|
|
197
|
-
+
|
|
198
|
-
const fixtures = [
|
|
199
|
-
[
|
|
200
|
-
'/api',
|
|
201
|
-
@@ -126,7 +132,8 @@
|
|
202
|
-
'api/company-e/[id]?limit=[limit].GET.200.json',
|
|
203
|
-
'with pretty-param and query-params'
|
|
204
|
-
],
|
|
205
|
-
- fixtureCustomMime
|
|
206
|
-
+ fixtureCustomMime,
|
|
207
|
-
+ fixtureCustomMethod
|
|
208
|
-
]
|
|
209
|
-
for (const [, file, body] of [fixtureNonDefaultInName, ...fixtures])
|
|
210
|
-
write(file, file.endsWith('.json') ? JSON.stringify(body) : body)
|
|
211
|
-
@@ -157,7 +164,8 @@
|
|
212
|
-
extraHeaders: ['Server', 'MockatonTester'],
|
|
213
|
-
extraMimes: {
|
|
214
|
-
my_custom_extension: 'my_custom_mime'
|
|
215
|
-
- }
|
|
216
|
-
+ },
|
|
217
|
-
+ customMethods: ['FOO']
|
|
218
|
-
})
|
|
219
|
-
server.on('listening', runTests)
|
|
220
|
-
|
|
221
|
-
@@ -257,6 +265,7 @@
|
|
222
|
-
const { urlMask, method, status } = parseFilename(file)
|
|
223
|
-
const mime = forcedMime || mimeFor(file)
|
|
224
|
-
const res = await request(url, { method })
|
|
225
|
-
+ console.log('method', res, method)
|
|
226
|
-
const body = mime === 'application/json'
|
|
227
|
-
? await res.json()
|
|
228
|
-
: await res.text()
|
|
229
|
-
Index: src/Config.js
|
|
230
|
-
IDEA additional info:
|
|
231
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
|
232
|
-
<+>import { openInBrowser } from './utils/openInBrowser.js'\nimport { validate, is, optional } from './utils/validate.js'\nimport { isDirectory } from './utils/fs.js'\n\n\nexport const Config = Object.seal({\n\tmocksDir: '',\n\tignore: /(\\.DS_Store|~)$/,\n\n\tstaticDir: '',\n\n\thost: '127.0.0.1',\n\tport: 0, // auto-assigned\n\tproxyFallback: '', // e.g. http://localhost:9999\n\n\tdelay: 1200, // milliseconds\n\tcookies: {}, // defaults to the first kv\n\textraHeaders: [],\n\textraMimes: {},\n\n\tonReady: openInBrowser\n})\n\n\nexport function setup(options) {\n\tObject.assign(Config, options)\n\tvalidate(Config, {\n\t\tmocksDir: isDirectory,\n\t\tignore: is(RegExp),\n\n\t\tstaticDir: optional(isDirectory),\n\n\t\thost: is(String),\n\t\tport: port => Number.isInteger(port) && port >= 0 && port < 2 ** 16,\n\t\tproxyFallback: optional(URL.canParse),\n\n\t\tdelay: ms => Number.isInteger(ms) && ms > 0,\n\t\tcookies: is(Object),\n\t\textraHeaders: Array.isArray,\n\t\textraMimes: is(Object),\n\n\t\tonReady: is(Function)\n\t})\n}\n\n\n
|
|
233
|
-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
|
234
|
-
<+>UTF-8
|
|
235
|
-
===================================================================
|
|
236
|
-
diff --git a/src/Config.js b/src/Config.js
|
|
237
|
-
--- a/src/Config.js (revision 016945139309b5f30833795740b816a95516ddcf)
|
|
238
|
-
+++ b/src/Config.js (date 1727485833948)
|
|
239
|
-
@@ -16,7 +16,9 @@
|
|
240
|
-
delay: 1200, // milliseconds
|
|
241
|
-
cookies: {}, // defaults to the first kv
|
|
242
|
-
extraHeaders: [],
|
|
243
|
-
+
|
|
244
|
-
extraMimes: {},
|
|
245
|
-
+ customMethods: [],
|
|
246
|
-
|
|
247
|
-
onReady: openInBrowser
|
|
248
|
-
})
|
|
249
|
-
@@ -36,8 +38,10 @@
|
|
250
|
-
|
|
251
|
-
delay: ms => Number.isInteger(ms) && ms > 0,
|
|
252
|
-
cookies: is(Object),
|
|
253
|
-
- extraHeaders: Array.isArray,
|
|
254
|
-
+ extraHeaders: val => Array.isArray(val) && val.length % 2 === 0,
|
|
255
|
-
+
|
|
256
|
-
extraMimes: is(Object),
|
|
257
|
-
+ customMethods: Array.isArray,
|
|
258
|
-
|
|
259
|
-
onReady: is(Function)
|
|
260
|
-
})
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<changelist name="custom_methods,_but_nodejs_does_not_support_them_https___github_com_nodejs_llhttp_pull_54" date="1727488181071" recycled="false">
|
|
2
|
-
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/custom_methods,_but_nodejs_does_not_support_them_https___github_com_nodejs_llhttp_pull_54/shelved.patch" />
|
|
3
|
-
<option name="DESCRIPTION" value="custom methods, but nodejs does not support them https://github.com/nodejs/llhttp/pull/54" />
|
|
4
|
-
</changelist>
|