Skip to content

Commit 2520ac3

Browse files
author
Alexander Kharkovey
committed
feat(json-api-nestjs-sdk): add init for react application
1 parent c8da9f8 commit 2520ac3

31 files changed

+8574
-207
lines changed

apps/example-react-client/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@nrwl/react/babel",
5+
{
6+
"runtime": "automatic"
7+
}
8+
]
9+
],
10+
"plugins": []
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by:
2+
# 1. autoprefixer to adjust CSS to support the below specified browsers
3+
# 2. babel preset-env to adjust included polyfills
4+
#
5+
# For additional information regarding the format and rule options, please see:
6+
# https://github.com/browserslist/browserslist#queries
7+
#
8+
# If you need to support different browsers in production, you may tweak the list below.
9+
10+
last 1 Chrome version
11+
last 1 Firefox version
12+
last 2 Edge major versions
13+
last 2 Safari major version
14+
last 2 iOS major versions
15+
Firefox ESR
16+
not IE 9-11 # For IE 9-11 support, remove 'not'.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'example-react-client',
4+
preset: '../../jest.preset.js',
5+
transform: {
6+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
7+
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }],
8+
},
9+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
10+
coverageDirectory: '../../coverage/apps/example-react-client',
11+
};
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"name": "example-react-client",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "apps/example-react-client/src",
5+
"projectType": "application",
6+
"targets": {
7+
"build": {
8+
"executor": "@nrwl/webpack:webpack",
9+
"outputs": ["{options.outputPath}"],
10+
"defaultConfiguration": "production",
11+
"options": {
12+
"compiler": "babel",
13+
"outputPath": "dist/apps/example-react-client",
14+
"index": "apps/example-react-client/src/index.html",
15+
"baseHref": "/",
16+
"main": "apps/example-react-client/src/main.tsx",
17+
"polyfills": "apps/example-react-client/src/polyfills.ts",
18+
"tsConfig": "apps/example-react-client/tsconfig.app.json",
19+
"assets": [
20+
"apps/example-react-client/src/favicon.ico",
21+
"apps/example-react-client/src/assets"
22+
],
23+
"styles": ["apps/example-react-client/src/styles.css"],
24+
"scripts": [],
25+
"webpackConfig": "apps/example-react-client/webpack.config.ts"
26+
},
27+
"configurations": {
28+
"development": {
29+
"extractLicenses": false,
30+
"optimization": false,
31+
"sourceMap": true,
32+
"vendorChunk": true
33+
},
34+
"production": {
35+
"fileReplacements": [
36+
{
37+
"replace": "apps/example-react-client/src/environments/environment.ts",
38+
"with": "apps/example-react-client/src/environments/environment.prod.ts"
39+
}
40+
],
41+
"optimization": true,
42+
"outputHashing": "all",
43+
"sourceMap": false,
44+
"namedChunks": false,
45+
"extractLicenses": true,
46+
"vendorChunk": false
47+
}
48+
}
49+
},
50+
"serve": {
51+
"executor": "@nrwl/webpack:dev-server",
52+
"defaultConfiguration": "development",
53+
"options": {
54+
"buildTarget": "example-react-client:build",
55+
"hmr": true,
56+
"proxyConfig": "apps/example-react-client/proxy.conf.json"
57+
},
58+
"configurations": {
59+
"development": {
60+
"buildTarget": "example-react-client:build:development"
61+
},
62+
"production": {
63+
"buildTarget": "example-react-client:build:production",
64+
"hmr": false
65+
}
66+
}
67+
},
68+
"lint": {
69+
"executor": "@nrwl/linter:eslint",
70+
"outputs": ["{options.outputFile}"],
71+
"options": {
72+
"lintFilePatterns": ["apps/example-react-client/**/*.{ts,tsx,js,jsx}"]
73+
}
74+
},
75+
"test": {
76+
"executor": "@nrwl/jest:jest",
77+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
78+
"options": {
79+
"jestConfig": "apps/example-react-client/jest.config.ts",
80+
"passWithNoTests": true
81+
}
82+
}
83+
},
84+
"tags": []
85+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"/api": {
3+
"target": "http://localhost:3333",
4+
"secure": false
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Your styles goes here. */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { render } from '@testing-library/react';
2+
3+
import App from './app';
4+
5+
describe('App', () => {
6+
it('should render successfully', () => {
7+
const { baseElement } = render(<App />);
8+
9+
expect(baseElement).toBeTruthy();
10+
});
11+
12+
it('should have a greeting as the title', () => {
13+
const { getByText } = render(<App />);
14+
15+
expect(getByText(/Welcome example-react-client/gi)).toBeTruthy();
16+
});
17+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import styles from './app.module.css';
2+
import NxWelcome from './nx-welcome';
3+
import { getInstance } from 'json-api-nestjs-sdk';
4+
import { BookList, Users, Roles, Comments, Addresses } from 'database/entity';
5+
6+
const service = getInstance(
7+
{
8+
apiPrefix: '/api/v1',
9+
apiHost: window.location.origin,
10+
},
11+
{
12+
BookList,
13+
Roles,
14+
Comments,
15+
Addresses,
16+
Users,
17+
}
18+
);
19+
20+
export function App() {
21+
service.getOne<Users>(Users, 17).subscribe((r) => console.log(r));
22+
return (
23+
<>
24+
<NxWelcome title="example-react-client" />
25+
<div />
26+
</>
27+
);
28+
}
29+
30+
export default App;

0 commit comments

Comments
 (0)