diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af38703b..85726ecd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: @@ -47,12 +48,15 @@ jobs: - name: Install dependencies run: npm i + working-directory: ./server - name: Build run: npm run build -- --noEmit + working-directory: ./server - name: Lint Code run: npm run lint + working-directory: ./server - name: Generate COOKIE Secret run: | @@ -61,6 +65,7 @@ jobs: - name: Generate dummy .env for scripts using -env-file=.env flag run: touch .env + working-directory: ./server - name: Test env: @@ -74,3 +79,4 @@ jobs: RATE_LIMIT_MAX: 4 CAN_SEED_DATABASE: 1 run: npm run db:migrate && npm run test + working-directory: ./server diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 35835fb2..c86b87ed 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1 +1 @@ -sonar.exclusions=test/**/*,scripts/seed-database.ts +sonar.exclusions=server/test/**/*,scripts/seed-database.ts diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/client/.prettierignore b/client/.prettierignore new file mode 100644 index 00000000..1b8ac889 --- /dev/null +++ b/client/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/client/.prettierrc b/client/.prettierrc new file mode 100644 index 00000000..e29d5016 --- /dev/null +++ b/client/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "jsxSingleQuote": true +} diff --git a/client/README.md b/client/README.md new file mode 100644 index 00000000..979049c4 --- /dev/null +++ b/client/README.md @@ -0,0 +1,68 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +## Getting started +Install the dependencies: +```bash +npm install +``` + +### Start the server +In dev mode: +```bash +npm run dev +``` + +### Build +To build the project: +```bash +npm run build +``` + +### Locally preview the production build +```bash +npm run preview +``` + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default tseslint.config({ + languageOptions: { + // other options... + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, +}) +``` + +- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` +- Optionally add `...tseslint.configs.stylisticTypeChecked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: + +```js +// eslint.config.js +import react from 'eslint-plugin-react' + +export default tseslint.config({ + // Set the react version + settings: { react: { version: '18.3' } }, + plugins: { + // Add the react plugin + react, + }, + rules: { + // other rules... + // Enable its recommended rules + ...react.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + }, +}) +``` diff --git a/client/eslint.config.js b/client/eslint.config.js new file mode 100644 index 00000000..092408a9 --- /dev/null +++ b/client/eslint.config.js @@ -0,0 +1,28 @@ +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-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/client/index.html b/client/index.html new file mode 100644 index 00000000..e4b78eae --- /dev/null +++ b/client/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/client/package.json b/client/package.json new file mode 100644 index 00000000..882a24e1 --- /dev/null +++ b/client/package.json @@ -0,0 +1,30 @@ +{ + "name": "client", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "react": "^19.0.0", + "react-dom": "^19.0.0" + }, + "devDependencies": { + "@eslint/js": "^9.19.0", + "@types/react": "^19.0.8", + "@types/react-dom": "^19.0.3", + "@vitejs/plugin-react": "^4.3.4", + "eslint": "^9.19.0", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.18", + "globals": "^15.14.0", + "prettier": "3.4.2", + "typescript": "~5.7.2", + "typescript-eslint": "^8.22.0", + "vite": "^6.1.0" + } +} diff --git a/client/public/vite.svg b/client/public/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/client/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/App.module.css b/client/src/App.module.css new file mode 100644 index 00000000..b9d355df --- /dev/null +++ b/client/src/App.module.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/client/src/App.tsx b/client/src/App.tsx new file mode 100644 index 00000000..174fe531 --- /dev/null +++ b/client/src/App.tsx @@ -0,0 +1,35 @@ +import { useState } from 'react'; +import reactLogo from './assets/react.svg'; +import viteLogo from '/vite.svg'; +import styles from './App.module.css'; + +function App() { + const [count, setCount] = useState(0); + + return ( + <> +
+ + Vite logo + + + React logo + +
+

Vite + React

+
+ +

+ Edit src/App.tsx and save to test HMR +

+
+

+ Click on the Vite and React logos to learn more +

+ + ); +} + +export default App; diff --git a/client/src/assets/react.svg b/client/src/assets/react.svg new file mode 100644 index 00000000..6c87de9b --- /dev/null +++ b/client/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/src/index.css b/client/src/index.css new file mode 100644 index 00000000..1dd69192 --- /dev/null +++ b/client/src/index.css @@ -0,0 +1,76 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/client/src/main.tsx b/client/src/main.tsx new file mode 100644 index 00000000..bef5202a --- /dev/null +++ b/client/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './index.css' +import App from './App.tsx' + +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/client/src/vite-env.d.ts b/client/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/client/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/client/tsconfig.app.json b/client/tsconfig.app.json new file mode 100644 index 00000000..358ca9ba --- /dev/null +++ b/client/tsconfig.app.json @@ -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"] +} diff --git a/client/tsconfig.json b/client/tsconfig.json new file mode 100644 index 00000000..1ffef600 --- /dev/null +++ b/client/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/client/tsconfig.node.json b/client/tsconfig.node.json new file mode 100644 index 00000000..db0becc8 --- /dev/null +++ b/client/tsconfig.node.json @@ -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"] +} diff --git a/client/vite.config.ts b/client/vite.config.ts new file mode 100644 index 00000000..8b0f57b9 --- /dev/null +++ b/client/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +}) diff --git a/.env.example b/server/.env.example similarity index 100% rename from .env.example rename to server/.env.example diff --git a/@types/node/environment.d.ts b/server/@types/node/environment.d.ts similarity index 100% rename from @types/node/environment.d.ts rename to server/@types/node/environment.d.ts diff --git a/README.md b/server/README.md similarity index 100% rename from README.md rename to server/README.md diff --git a/docker-compose.yml b/server/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to server/docker-compose.yml diff --git a/eslint.config.js b/server/eslint.config.js similarity index 100% rename from eslint.config.js rename to server/eslint.config.js diff --git a/migrations/001.do.users.sql b/server/migrations/001.do.users.sql similarity index 100% rename from migrations/001.do.users.sql rename to server/migrations/001.do.users.sql diff --git a/migrations/001.undo.users.sql b/server/migrations/001.undo.users.sql similarity index 100% rename from migrations/001.undo.users.sql rename to server/migrations/001.undo.users.sql diff --git a/migrations/002.do.tasks.sql b/server/migrations/002.do.tasks.sql similarity index 100% rename from migrations/002.do.tasks.sql rename to server/migrations/002.do.tasks.sql diff --git a/migrations/002.undo.tasks.sql b/server/migrations/002.undo.tasks.sql similarity index 100% rename from migrations/002.undo.tasks.sql rename to server/migrations/002.undo.tasks.sql diff --git a/migrations/003.do.user_tasks.sql b/server/migrations/003.do.user_tasks.sql similarity index 100% rename from migrations/003.do.user_tasks.sql rename to server/migrations/003.do.user_tasks.sql diff --git a/migrations/003.undo.user_tasks.sql b/server/migrations/003.undo.user_tasks.sql similarity index 100% rename from migrations/003.undo.user_tasks.sql rename to server/migrations/003.undo.user_tasks.sql diff --git a/migrations/004.do.roles.sql b/server/migrations/004.do.roles.sql similarity index 100% rename from migrations/004.do.roles.sql rename to server/migrations/004.do.roles.sql diff --git a/migrations/004.undo.roles.sql b/server/migrations/004.undo.roles.sql similarity index 100% rename from migrations/004.undo.roles.sql rename to server/migrations/004.undo.roles.sql diff --git a/migrations/005.do.user_roles.sql b/server/migrations/005.do.user_roles.sql similarity index 100% rename from migrations/005.do.user_roles.sql rename to server/migrations/005.do.user_roles.sql diff --git a/migrations/005.undo.user_roles.sql b/server/migrations/005.undo.user_roles.sql similarity index 100% rename from migrations/005.undo.user_roles.sql rename to server/migrations/005.undo.user_roles.sql diff --git a/package.json b/server/package.json similarity index 100% rename from package.json rename to server/package.json diff --git a/scripts/create-database.ts b/server/scripts/create-database.ts similarity index 100% rename from scripts/create-database.ts rename to server/scripts/create-database.ts diff --git a/scripts/drop-database.ts b/server/scripts/drop-database.ts similarity index 100% rename from scripts/drop-database.ts rename to server/scripts/drop-database.ts diff --git a/scripts/migrate.ts b/server/scripts/migrate.ts similarity index 100% rename from scripts/migrate.ts rename to server/scripts/migrate.ts diff --git a/scripts/seed-database.ts b/server/scripts/seed-database.ts similarity index 100% rename from scripts/seed-database.ts rename to server/scripts/seed-database.ts diff --git a/src/app.ts b/server/src/app.ts similarity index 100% rename from src/app.ts rename to server/src/app.ts diff --git a/src/plugins/README.md b/server/src/plugins/README.md similarity index 100% rename from src/plugins/README.md rename to server/src/plugins/README.md diff --git a/src/plugins/custom/authorization.ts b/server/src/plugins/custom/authorization.ts similarity index 100% rename from src/plugins/custom/authorization.ts rename to server/src/plugins/custom/authorization.ts diff --git a/src/plugins/custom/scrypt.ts b/server/src/plugins/custom/scrypt.ts similarity index 100% rename from src/plugins/custom/scrypt.ts rename to server/src/plugins/custom/scrypt.ts diff --git a/src/plugins/external/cors.ts b/server/src/plugins/external/cors.ts similarity index 100% rename from src/plugins/external/cors.ts rename to server/src/plugins/external/cors.ts diff --git a/src/plugins/external/env.ts b/server/src/plugins/external/env.ts similarity index 100% rename from src/plugins/external/env.ts rename to server/src/plugins/external/env.ts diff --git a/src/plugins/external/helmet.ts b/server/src/plugins/external/helmet.ts similarity index 100% rename from src/plugins/external/helmet.ts rename to server/src/plugins/external/helmet.ts diff --git a/src/plugins/external/knex.ts b/server/src/plugins/external/knex.ts similarity index 100% rename from src/plugins/external/knex.ts rename to server/src/plugins/external/knex.ts diff --git a/src/plugins/external/multipart.ts b/server/src/plugins/external/multipart.ts similarity index 100% rename from src/plugins/external/multipart.ts rename to server/src/plugins/external/multipart.ts diff --git a/src/plugins/external/rate-limit.ts b/server/src/plugins/external/rate-limit.ts similarity index 100% rename from src/plugins/external/rate-limit.ts rename to server/src/plugins/external/rate-limit.ts diff --git a/src/plugins/external/sensible.ts b/server/src/plugins/external/sensible.ts similarity index 100% rename from src/plugins/external/sensible.ts rename to server/src/plugins/external/sensible.ts diff --git a/src/plugins/external/session.ts b/server/src/plugins/external/session.ts similarity index 100% rename from src/plugins/external/session.ts rename to server/src/plugins/external/session.ts diff --git a/src/plugins/external/static.ts b/server/src/plugins/external/static.ts similarity index 100% rename from src/plugins/external/static.ts rename to server/src/plugins/external/static.ts diff --git a/src/plugins/external/swagger.ts b/server/src/plugins/external/swagger.ts similarity index 100% rename from src/plugins/external/swagger.ts rename to server/src/plugins/external/swagger.ts diff --git a/src/plugins/external/under-pressure.ts b/server/src/plugins/external/under-pressure.ts similarity index 100% rename from src/plugins/external/under-pressure.ts rename to server/src/plugins/external/under-pressure.ts diff --git a/src/routes/README.md b/server/src/routes/README.md similarity index 100% rename from src/routes/README.md rename to server/src/routes/README.md diff --git a/src/routes/api/auth/index.ts b/server/src/routes/api/auth/index.ts similarity index 100% rename from src/routes/api/auth/index.ts rename to server/src/routes/api/auth/index.ts diff --git a/src/routes/api/autohooks.ts b/server/src/routes/api/autohooks.ts similarity index 100% rename from src/routes/api/autohooks.ts rename to server/src/routes/api/autohooks.ts diff --git a/src/routes/api/index.ts b/server/src/routes/api/index.ts similarity index 100% rename from src/routes/api/index.ts rename to server/src/routes/api/index.ts diff --git a/src/routes/api/tasks/index.ts b/server/src/routes/api/tasks/index.ts similarity index 100% rename from src/routes/api/tasks/index.ts rename to server/src/routes/api/tasks/index.ts diff --git a/src/routes/api/users/index.ts b/server/src/routes/api/users/index.ts similarity index 100% rename from src/routes/api/users/index.ts rename to server/src/routes/api/users/index.ts diff --git a/src/routes/home.ts b/server/src/routes/home.ts similarity index 100% rename from src/routes/home.ts rename to server/src/routes/home.ts diff --git a/src/schemas/auth.ts b/server/src/schemas/auth.ts similarity index 100% rename from src/schemas/auth.ts rename to server/src/schemas/auth.ts diff --git a/src/schemas/common.ts b/server/src/schemas/common.ts similarity index 100% rename from src/schemas/common.ts rename to server/src/schemas/common.ts diff --git a/src/schemas/tasks.ts b/server/src/schemas/tasks.ts similarity index 100% rename from src/schemas/tasks.ts rename to server/src/schemas/tasks.ts diff --git a/src/schemas/users.ts b/server/src/schemas/users.ts similarity index 100% rename from src/schemas/users.ts rename to server/src/schemas/users.ts diff --git a/src/server.ts b/server/src/server.ts similarity index 100% rename from src/server.ts rename to server/src/server.ts diff --git a/test/app/cors.test.ts b/server/test/app/cors.test.ts similarity index 100% rename from test/app/cors.test.ts rename to server/test/app/cors.test.ts diff --git a/test/app/error-handler.test.ts b/server/test/app/error-handler.test.ts similarity index 100% rename from test/app/error-handler.test.ts rename to server/test/app/error-handler.test.ts diff --git a/test/app/not-found-handler.test.ts b/server/test/app/not-found-handler.test.ts similarity index 100% rename from test/app/not-found-handler.test.ts rename to server/test/app/not-found-handler.test.ts diff --git a/test/app/rate-limit.test.ts b/server/test/app/rate-limit.test.ts similarity index 100% rename from test/app/rate-limit.test.ts rename to server/test/app/rate-limit.test.ts diff --git a/test/helper.ts b/server/test/helper.ts similarity index 100% rename from test/helper.ts rename to server/test/helper.ts diff --git a/test/plugins/scrypt.test.ts b/server/test/plugins/scrypt.test.ts similarity index 100% rename from test/plugins/scrypt.test.ts rename to server/test/plugins/scrypt.test.ts diff --git a/test/routes/api/api.test.ts b/server/test/routes/api/api.test.ts similarity index 100% rename from test/routes/api/api.test.ts rename to server/test/routes/api/api.test.ts diff --git a/test/routes/api/auth/auth.test.ts b/server/test/routes/api/auth/auth.test.ts similarity index 100% rename from test/routes/api/auth/auth.test.ts rename to server/test/routes/api/auth/auth.test.ts diff --git a/test/routes/api/tasks/fixtures/one_line.csv b/server/test/routes/api/tasks/fixtures/one_line.csv similarity index 100% rename from test/routes/api/tasks/fixtures/one_line.csv rename to server/test/routes/api/tasks/fixtures/one_line.csv diff --git a/test/routes/api/tasks/fixtures/short-logo.png b/server/test/routes/api/tasks/fixtures/short-logo.png similarity index 100% rename from test/routes/api/tasks/fixtures/short-logo.png rename to server/test/routes/api/tasks/fixtures/short-logo.png diff --git a/test/routes/api/tasks/tasks.test.ts b/server/test/routes/api/tasks/tasks.test.ts similarity index 100% rename from test/routes/api/tasks/tasks.test.ts rename to server/test/routes/api/tasks/tasks.test.ts diff --git a/test/routes/api/users/users.test.ts b/server/test/routes/api/users/users.test.ts similarity index 100% rename from test/routes/api/users/users.test.ts rename to server/test/routes/api/users/users.test.ts diff --git a/test/routes/home.test.ts b/server/test/routes/home.test.ts similarity index 100% rename from test/routes/home.test.ts rename to server/test/routes/home.test.ts diff --git a/test/tsconfig.json b/server/test/tsconfig.json similarity index 100% rename from test/tsconfig.json rename to server/test/tsconfig.json diff --git a/tsconfig.json b/server/tsconfig.json similarity index 100% rename from tsconfig.json rename to server/tsconfig.json