Skip to content

Commit

Permalink
feat(dev): mock API server with miragejs (#1039) (#1098)
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <[email protected]>
(cherry picked from commit b9d9557)

Co-authored-by: Thuan Vo <[email protected]>
  • Loading branch information
mergify[bot] and Thuan Vo authored Aug 31, 2023
1 parent 6b9414b commit b7df7ce
Show file tree
Hide file tree
Showing 11 changed files with 1,111 additions and 45 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

1 change: 0 additions & 1 deletion .env.prod

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"scripts": {
"build": "npm-run-all -l build:notests test",
"build:notests": "webpack --config webpack.prod.js",
"build:preview:notests": "PREVIEW=true webpack --config webpack.prod.js",
"clean": "rimraf dist",
"start:dev": "webpack serve --hot --color --progress --config webpack.dev.js",
"start:dev:preview": "PREVIEW=true PORT=9091 webpack serve --hot --color --progress --config webpack.dev.js",
"start:dev:lint": "ESLINT_ENABLE=true webpack serve --hot --color --progress --config webpack.dev.js",
"test": "jest --maxWorkers=50% --coverage=true",
"test:ci": "jest --maxWorkers=50%",
Expand Down Expand Up @@ -45,7 +47,6 @@
"@typescript-eslint/parser": "^5.53.0",
"css-loader": "^6.7.3",
"css-minimizer-webpack-plugin": "^4.2.2",
"dotenv-webpack": "^8.0.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.7",
"enzyme-to-json": "^3.6.2",
Expand All @@ -64,6 +65,8 @@
"license-check-and-add": "^4.0.5",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^2.7.1",
"miragejs": "^0.1.47",
"mock-socket": "^9.2.1",
"nanoid": "^3.3.4",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.4",
Expand All @@ -77,7 +80,7 @@
"rxjs": "^7.8.0",
"style-loader": "^3.3.1",
"svg-url-loader": "^8.0.0",
"terser-webpack-plugin": "^5.3.3",
"terser-webpack-plugin": "^5.3.9",
"ts-jest": "^27.0.5",
"ts-loader": "^9.4.2",
"tsconfig-paths-webpack-plugin": "^4.0.0",
Expand Down
56 changes: 56 additions & 0 deletions src/mirage/factories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright The Cryostat Authors
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or data
* (collectively the "Software"), free of charge and under any and all copyright
* rights in the Software, and any and all patent rights owned or freely
* licensable by each licensor hereunder covering either (i) the unmodified
* Software as contributed to or provided by such licensor, or (ii) the Larger
* Works (as defined below), to deal in both
*
* (a) the Software, and
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software (each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
* The above copyright notice and either this complete permission notice or at
* a minimum a reference to the UPL must be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import { Factory } from 'miragejs';
import { FactoryDefinition } from 'miragejs/-types';
import { Resource } from './typings';

export const targetFactory: FactoryDefinition<any> = Factory.extend({
alias: 'Fake Target',
connectUrl: 'http://fake-target.local:1234',
jvmId: '1234',
annotations: {
platform: { 'io.cryostat.demo': 'this-is-not-real' },
cryostat: { hello: 'world' },
},
});

export const factories = {
[Resource.TARGET]: targetFactory,
};

export default factories;
Loading

0 comments on commit b7df7ce

Please sign in to comment.