Template
README po polsku
This commit is contained in:
@@ -1,43 +1,46 @@
|
||||
# Nuxt Boilerplate
|
||||
|
||||
Starter for the Nuxt coursework workspace: Bun + Nuxt + TypeScript + Tailwind,
|
||||
with MySQL (Drizzle ORM) and Redis wired up to the shared course databases.
|
||||
Szablon startowy do zajęć z Nuxt: Bun + Nuxt + TypeScript + Tailwind, z
|
||||
podpiętym MySQL (Drizzle ORM) i Redisem do wspólnych baz danych z kursu.
|
||||
|
||||
## Development
|
||||
## Uruchomienie
|
||||
```bash
|
||||
bun install
|
||||
bun run db:push # creates the `notes` table from server/db/schema.ts
|
||||
bun run db:push # tworzy tabelę `notes` z server/db/schema.ts
|
||||
bun run dev
|
||||
```
|
||||
|
||||
Open http://localhost:3000 - the home page shows a small notes list (MySQL)
|
||||
and a key/value box (Redis) so you can see both connections working.
|
||||
Strona główna pokazuje krótką listę notatek (MySQL) i pole klucz/wartość
|
||||
(Redis), żeby od razu było widać, że oba połączenia działają.
|
||||
|
||||
## What's here
|
||||
- `app/pages/index.vue` - example page using `<template lang="pug">`, calling
|
||||
the API routes below via `useFetch`/`$fetch`. Delete once you understand the
|
||||
pattern and start building your own pages.
|
||||
- `server/api/notes.get.ts` / `notes.post.ts` - example MySQL reads/writes via
|
||||
Drizzle.
|
||||
- `server/api/cache/[key].get.ts` / `[key].put.ts` - example Redis reads/writes.
|
||||
- `server/db/schema.ts` - your Drizzle table definitions. Add tables here, then
|
||||
run `bun run db:push` to sync them to MySQL (no migration files needed for
|
||||
coursework - `push` just diffs your schema against the live database).
|
||||
- `server/db/index.ts` / `server/utils/redis.ts` - pre-configured clients,
|
||||
reading connection details from environment variables. In your Coder
|
||||
workspace these are already set for you (`MYSQL_*`, `REDIS_*`) - you never
|
||||
need to type a password into code.
|
||||
- `.env.example` - only needed if you want to run this outside your Coder
|
||||
workspace, against your own local MySQL/Redis.
|
||||
- `.gitea/workflows/deploy.yml` - deploys to Vercel on push to `main`, but
|
||||
only if you've set `VERCEL_TOKEN` (and `VERCEL_ORG_ID`/`VERCEL_PROJECT_ID`)
|
||||
as repo secrets. Without them the job is skipped - nothing breaks.
|
||||
## Co tu jest
|
||||
- `app/pages/index.vue` - przykładowa strona z `<template lang="pug">`,
|
||||
która korzysta z endpointów opisanych niżej przez `useFetch`/`$fetch`.
|
||||
Usuń ją, gdy zrozumiesz zasadę działania i zaczniesz tworzyć własne strony.
|
||||
- `server/api/notes.get.ts` / `notes.post.ts` - przykładowy odczyt i zapis
|
||||
do MySQL przez Drizzle.
|
||||
- `server/api/cache/[key].get.ts` / `[key].put.ts` - przykładowy odczyt i
|
||||
zapis do Redisa.
|
||||
- `server/db/schema.ts` - definicje tabel w Drizzle. Dodawaj tu kolejne
|
||||
tabele, a potem uruchom `bun run db:push`, żeby zsynchronizować je z bazą
|
||||
MySQL (bez plików migracji - `push` po prostu porównuje schemat z bazą
|
||||
na żywo).
|
||||
- `server/db/index.ts` / `server/utils/redis.ts` - gotowe klienty, które
|
||||
czytają dane połączenia ze zmiennych środowiskowych. W Twoim workspace
|
||||
w Coderze są one już ustawione (`MYSQL_*`, `REDIS_*`) - nie musisz nigdzie
|
||||
wpisywać hasła.
|
||||
- `.env.example` - potrzebne tylko, jeśli chcesz uruchomić projekt poza
|
||||
workspace'em w Coderze, na własnym MySQL/Redis.
|
||||
- `.gitea/workflows/deploy.yml` - wdraża projekt na Vercel przy pushu do
|
||||
`main`, ale tylko jeśli ustawisz `VERCEL_TOKEN` (i `VERCEL_ORG_ID`/
|
||||
`VERCEL_PROJECT_ID`) jako sekrety repozytorium. Bez nich zadanie jest
|
||||
pomijane - nic się nie psuje.
|
||||
|
||||
## Notes
|
||||
- Your Redis user can only touch keys under `student:<your-username>:*`
|
||||
(enforced by the server) - that's why the cache routes prefix keys with
|
||||
`REDIS_USERNAME`. Keys outside that prefix will be rejected.
|
||||
- Your MySQL user only has access to your own database - no need to specify
|
||||
it beyond what's already in `MYSQL_DATABASE`.
|
||||
- Tailwind classes are available everywhere via `@nuxtjs/tailwindcss` - no
|
||||
extra CSS file needed for basic usage.
|
||||
## Uwagi
|
||||
- Twój użytkownik Redis widzi tylko klucze pod `student:<twoja-nazwa>:*`
|
||||
(wymuszone po stronie serwera) - dlatego endpointy cache dodają ten
|
||||
prefiks do kluczy. Klucze spoza tego prefiksu zostaną odrzucone.
|
||||
- Twój użytkownik MySQL ma dostęp tylko do swojej własnej bazy - nie musisz
|
||||
nic dodatkowo podawać poza tym, co jest już w `MYSQL_DATABASE`.
|
||||
- Klasy Tailwinda działają wszędzie dzięki `@nuxtjs/tailwindcss` - do
|
||||
podstawowego użycia nie potrzeba dodatkowego pliku CSS.
|
||||
|
||||
Reference in New Issue
Block a user