Add support for React Native

This commit is contained in:
minec 2025-04-10 00:44:45 +02:00
parent e941dc18a4
commit bdbe89cee0
23 changed files with 13169 additions and 3488 deletions

12
.gitignore vendored
View File

@ -1,3 +1,11 @@
# Root
node_modules/ node_modules/
database.sqlite
dist/ # Backend
backend/node_modules/
backend/database.sqlite
backend/dist/
# Frontend
frontend/node_modules
frontend/build

5393
backend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

18
backend/package.json Normal file
View File

@ -0,0 +1,18 @@
{
"dependencies": {
"-": "^0.0.1",
"fastify": "^5.2.2",
"graphql": "^16.10.0",
"mercurius": "^16.1.0",
"metadata": "^0.1.0",
"reflect": "^0.1.3",
"reflect-metadata": "^0.2.2",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.21",
"typeorm-fastify-plugin": "^3.0.0"
},
"devDependencies": {
"@types/node": "^22.13.14",
"@vitejs/plugin-react": "^4.3.4"
}
}

View File

@ -73,7 +73,7 @@ fastify.register(mercurius, {
graphiql: true graphiql: true
}) })
fastify.listen({ port: 3000}, function (err, address) { fastify.listen({ port: 3001, host: '127.0.0.1'}, function (err, address) {
if (err) { if (err) {
fastify.log.error(err); fastify.log.error(err);
process.exit(1); process.exit(1);

7
frontend/.eslintrc Normal file
View File

@ -0,0 +1,7 @@
{
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"]
}
}

4
frontend/.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"singleQuote": false,
"printWidth": 120,
}

32
frontend/eslint.config.js Normal file
View File

@ -0,0 +1,32 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react/prop-types': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
);

12
frontend/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Test react page</title>
<link rel="icon" href="/favicon.ico"/>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

5860
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

36
frontend/package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "index.js",
"devDependencies": {
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.2",
"@typescript-eslint/eslint-plugin": "^8.29.1",
"@typescript-eslint/parser": "^8.29.1",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^8.57.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^4.6.2",
"typescript": "^5.8.3",
"vite": "^6.2.5"
},
"scripts": {
"start": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0",
"vite-tsconfig-paths": "^5.1.4"
}
}

9
frontend/src/App.tsx Normal file
View File

@ -0,0 +1,9 @@
function App() {
return (
<div style={{ padding: '2rem' }}>
<h1>Hello from React!</h1>
</div>
);
}
export default App

9
frontend/src/main.tsx Normal file
View File

@ -0,0 +1,9 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)

1
frontend/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

7
frontend/tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

17
frontend/vite.config.js Normal file
View File

@ -0,0 +1,17 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig(() => {
return {
build: {
outDir: 'build',
},
plugins: [react(), viteTsconfigPaths()],
server: {
proxy: {
'/graphql': 'http://localhost:3001'
}
}
};
});

5183
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,8 @@
{ {
"dependencies": { "private": true,
"-": "^0.0.1", "scripts": {
"fastify": "^5.2.2", "dev": "npm-run-all --parallel dev:*",
"graphql": "^16.10.0", "dev:backend": "cd backend && npx ts-node src/index.ts",
"mercurius": "^16.1.0", "dev:frontend": "cd frontend && npm start"
"metadata": "^0.1.0",
"reflect": "^0.1.3",
"reflect-metadata": "^0.2.2",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.21",
"typeorm-fastify-plugin": "^3.0.0"
},
"devDependencies": {
"@types/node": "^22.13.14"
} }
} }