From 94b8f28fe064b3acf9967733c8b4f65e96f41e39 Mon Sep 17 00:00:00 2001 From: Artem Bulgakov Date: Tue, 19 Nov 2024 05:54:00 +0300 Subject: [PATCH] docs: simplify development run --- .env.example => .env | 0 .gitignore | 2 +- README.md | 43 ++++++++++++++++++++++------------------- docker-compose.yaml | 11 ----------- nginx-server.conf | 46 -------------------------------------------- vite.config.ts | 4 +++- 6 files changed, 27 insertions(+), 79 deletions(-) rename .env.example => .env (100%) delete mode 100644 docker-compose.yaml delete mode 100644 nginx-server.conf diff --git a/.env.example b/.env similarity index 100% rename from .env.example rename to .env diff --git a/.gitignore b/.gitignore index 45aeb6c..2f0d2d2 100755 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ yarn-debug.log* yarn-error.log* # secrets -.env .env*.local *.pem @@ -27,3 +26,4 @@ yarn-error.log* # misc .DS_Store +. \ No newline at end of file diff --git a/README.md b/README.md index 557e43a..5ff6c83 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- InNoHassle + InNoHassle

@@ -49,7 +49,7 @@ The website uses the API of InNoHassle services: [Events](https://github.com/one ### Technologies -- [Node.js 20+](https://nodejs.org) & [TypeScript](https://www.typescriptlang.org/) +- [Node.js](https://nodejs.org) & [TypeScript](https://www.typescriptlang.org/) - [React](https://react.dev/) & [Vite](https://vitejs.dev/) & [TanStack Router](https://tanstack.com/router/latest/docs/framework/react/overview) - [Vue](https://vuejs.org/) & [Veaury](https://github.com/gloriasoft/veaury) - Styling: [TailwindCSS](https://tailwindcss.com/), [Iconify](https://iconify.design/) @@ -59,32 +59,35 @@ The website uses the API of InNoHassle services: [Events](https://github.com/one ## Development -### Getting started +### Set up for development -1. Install Node.js 20+, pnpm +1. Install [Node.js 20+](https://nodejs.org), [pnpm](https://pnpm.io) 2. Install dependencies: `pnpm install` -3. Set up pre-commit hooks (for formatting and linting): `pnpm run prepare` -4. Copy environment variables file: `cp .env.example .env.local` -5. Edit variables in `.env.local` if you want to use a different API server - > Do not change the ID of the trackers so that they are not enabled in development -6. Set up your IDE to autoformat code with Prettier and use ESLint - -When the API types change, run `pnpm run gen:api` to generate new client types and functions. - -### Run for development - -1. Start development server: `pnpm run dev` -2. Add `127.0.0.1 local.innohassle.ru` to your `/etc/hosts` file (on Windows: `C:\Windows\System32\drivers\etc\hosts`). -3. Open in the browser: https://local.innohassle.ru:3000 or https://localhost:3000 +3. Start development server: `pnpm run dev` +4. Open in the browser: https://local.innohassle.ru:3000 > The page will be reloaded when you edit the code -You must use HTTPS with domain https://local.innohassle.ru:3000 to access APIs with your account. +> [!IMPORTANT] +> You must use HTTPS with domain https://local.innohassle.ru:3000 to access APIs with your account. -### Run for production +> [!TIP] +> When the API types change, you can run `pnpm run gen:api` to generate new client types and functions. + +### Preview production build 1. Build the application: `pnpm run build` 2. Run the production-like server: `pnpm run preview` -3. Open in the browser: http://localhost:3000 +3. Open in the browser: https://local.innohassle.ru:3000 + +### Project structure + +- `src/` - main source code + - `app/` - entry point of the application + - `routes` - routing via [TanStack Router](https://tanstack.com/router/latest/docs/framework/react/guide/file-based-routing) + - `components/` - components split by pages + - `lib/` - utilities and domain-specific logic + - `api/` - API clients and types +- `public/` - static files ## Contributing diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 0c6b971..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,11 +0,0 @@ -services: - nginx-proxy: - image: nginx - ports: - - "80:80" - - "443:443" - network_mode: host - # Generate a self-signed certificate for local.innohassle.ru - command: /bin/sh -c "openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj '/CN=local.innohassle.ru'; nginx -g 'daemon off;'" - volumes: - - ./nginx-server.conf:/etc/nginx/conf.d/default.conf diff --git a/nginx-server.conf b/nginx-server.conf deleted file mode 100644 index af83d62..0000000 --- a/nginx-server.conf +++ /dev/null @@ -1,46 +0,0 @@ -# To start development https server, run: docker compose up --detach -# Then configure your /etc/hosts: 127.0.0.1 local.innohassle.ru -# And visit https://local.innohassle.ru - -server { - listen 80 default_server; - - location / { - # Set proxy headers - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # Enable WebSockets - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - - # Proxy requests to port 3000 - proxy_pass http://127.0.0.1:3000; - } -} - -server { - listen 443 ssl; - ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt; - ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key; - ssl_protocols TLSv1.2 TLSv1.1 TLSv1; - - location / { - # Set proxy headers - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # Enable WebSockets - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - - # Proxy requests to port 3000 - proxy_pass http://127.0.0.1:3000; - } -} diff --git a/vite.config.ts b/vite.config.ts index 51315e7..333ba58 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,7 +14,9 @@ import { version } from "./package.json"; export default defineConfig({ plugins: [ // HTTPS support in development - mkcert(), + mkcert({ + hosts: ["local.innohassle.ru"], + }), // Enable routing via TanStack Router TanStackRouterVite({