[FA-18] Frontend bootstrapped

This commit is contained in:
gamer147
2025-11-24 13:25:29 -05:00
parent 16ed16ff62
commit e8596b67c4
42 changed files with 9747 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
# FictionArchive React Starter
A minimal React + Vite + Apollo Client scaffold ready to connect to the FictionArchive Fusion gateway. Point it at your own endpoint by changing `VITE_GRAPHQL_URI`.
## Getting started
```bash
cd fictionarchive-web
npm install
npm run dev
```
Then open the printed local URL. Update `.env` (create it if missing) with your endpoint:
```
VITE_GRAPHQL_URI=https://localhost:5001/graphql
VITE_OIDC_AUTHORITY=https://your-idp
VITE_OIDC_CLIENT_ID=fictionarchive-web
VITE_OIDC_REDIRECT_URI=http://localhost:5173
VITE_OIDC_POST_LOGOUT_REDIRECT_URI=http://localhost:5173
# Optional: token used only by codegen if your gateway requires auth
VITE_CODEGEN_TOKEN=your_api_token
```
## Scripts
- `npm run dev`: start Vite dev server.
- `npm run build`: type-check + build (runs codegen first via `prebuild`).
- `npm run codegen`: generate typed hooks from `src/**/*.graphql` into `src/__generated__/graphql.ts`.
## Project notes
- `src/apolloClient.ts` configures the Apollo client with `InMemoryCache` and reads `VITE_GRAPHQL_URI`.
- GraphQL code generation is configured via `codegen.ts` (loads `.env`/`.env.local` automatically); run `npm run codegen` to emit typed hooks to `src/__generated__/graphql.ts` (ignored by git) or rely on the `prebuild` hook.
- Routing is handled in `src/App.tsx` with `react-router-dom`; `/` renders the novels listing and `/novels/:id` is stubbed for future detail pages.
- Styles live primarily in `src/index.css` alongside the shared UI components.
## Codegen tips
- Default schema URL: `CODEGEN_SCHEMA_URL` (falls back to `VITE_GRAPHQL_URI`, then `https://localhost:5001/graphql`).
- Add `VITE_CODEGEN_TOKEN` (or `CODEGEN_TOKEN`) if your gateway requires a bearer token during introspection.
- Generated outputs land in `src/__generated__/graphql.ts` (git-ignored). Run `npm run codegen` after schema/operation changes or rely on `npm run build` (runs `prebuild`).