|
| 1 | +# Quick Start Guide |
| 2 | + |
| 3 | +## Start the Application |
| 4 | + |
| 5 | +```bash |
| 6 | +npm run start:dev |
| 7 | +``` |
| 8 | + |
| 9 | +## Access Documentation |
| 10 | + |
| 11 | +| Type | URL | Purpose | |
| 12 | +|------|-----|---------| |
| 13 | +| **REST API** | http://localhost:4005/api | Swagger UI for REST endpoints | |
| 14 | +| **GraphQL API** | http://localhost:4005/graphql | GraphQL Playground for queries/mutations | |
| 15 | + |
| 16 | +## Authentication |
| 17 | + |
| 18 | +### Get Your JWT Token |
| 19 | +1. Login to your Keycloak instance |
| 20 | +2. Copy the JWT token from your session |
| 21 | + |
| 22 | +### Use in Swagger (REST API) |
| 23 | +1. Click **"Authorize"** button (top right) |
| 24 | +2. Paste your token |
| 25 | +3. Click **"Authorize"** then **"Close"** |
| 26 | + |
| 27 | +### Use in GraphQL Playground |
| 28 | +1. Click **"HTTP HEADERS"** (bottom left) |
| 29 | +2. Add: |
| 30 | +```json |
| 31 | +{ |
| 32 | + "Authorization": "Bearer YOUR_TOKEN_HERE" |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +## Quick Examples |
| 37 | + |
| 38 | +### REST: Upload Files |
| 39 | +``` |
| 40 | +POST /cats/uploadFiles |
| 41 | +- files: [select files] |
| 42 | +- bucketId: "invoice-attachments" |
| 43 | +- invoiceId: 12345 |
| 44 | +``` |
| 45 | + |
| 46 | +### REST: Send Email |
| 47 | +``` |
| 48 | +POST /cats/sendEmail |
| 49 | +- file: [optional PDF] |
| 50 | +- invoiceId: 12345 |
| 51 | +- to: ["email@example.com"] |
| 52 | +- subject: "Invoice" |
| 53 | +- body: "Your invoice" |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | +### REST: Add User to Group |
| 58 | +``` |
| 59 | +POST /users/addGroup |
| 60 | +- userId: "123e4567-e89b-12d3-a456-426614174000" |
| 61 | +``` |
| 62 | + |
| 63 | +### GraphQL: Get All Persons |
| 64 | +```graphql |
| 65 | +query { |
| 66 | + findAllPerson { |
| 67 | + data { |
| 68 | + id |
| 69 | + firstName |
| 70 | + lastName |
| 71 | + email |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### GraphQL: Search Applications |
| 78 | +```graphql |
| 79 | +query { |
| 80 | + searchApplications( |
| 81 | + searchParam: "" |
| 82 | + page: 1 |
| 83 | + pageSize: 10 |
| 84 | + filter: ALL |
| 85 | + ) { |
| 86 | + count |
| 87 | + applications { |
| 88 | + id |
| 89 | + siteAddress |
| 90 | + status |
| 91 | + } |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### GraphQL: Create Invoice |
| 97 | +```graphql |
| 98 | +mutation { |
| 99 | + createInvoice(invoice: { |
| 100 | + personId: "123" |
| 101 | + subject: "Application Fee" |
| 102 | + issuedDate: "2024-01-15T00:00:00Z" |
| 103 | + dueDate: "2024-02-15T00:00:00Z" |
| 104 | + invoiceStatus: DRAFT |
| 105 | + taxExempt: false |
| 106 | + pstExempt: false |
| 107 | + subtotalInCents: 50000 |
| 108 | + gstInCents: 2500 |
| 109 | + pstInCents: 3500 |
| 110 | + totalInCents: 56000 |
| 111 | + applicationId: 456 |
| 112 | + invoiceItems: [{ |
| 113 | + description: "Review Fee" |
| 114 | + quantity: 1 |
| 115 | + unitPriceInCents: 50000 |
| 116 | + totalInCents: 50000 |
| 117 | + itemType: "SERVICE" |
| 118 | + }] |
| 119 | + }) { |
| 120 | + message |
| 121 | + success |
| 122 | + data { id } |
| 123 | + } |
| 124 | +} |
| 125 | +``` |
| 126 | + |
| 127 | +## Need More Help? |
| 128 | + |
| 129 | +- **REST API Documentation**: See `SWAGGER_DOCUMENTATION.md` for complete REST endpoint details |
| 130 | +- **GraphQL Examples**: See `GRAPHQL_QUERIES_MUTATIONS.md` for all queries and mutations with examples |
| 131 | + |
| 132 | +## Common Issues |
| 133 | + |
| 134 | +### Swagger UI: "Authorize" button not working |
| 135 | +- Make sure your JWT token is valid and not expired |
| 136 | +- Token should NOT include the "Bearer " prefix when pasting |
| 137 | +- Check Keycloak is running and accessible |
| 138 | + |
| 139 | +### GraphQL Playground: Authentication errors |
| 140 | +- Verify the Authorization header format: `"Authorization": "Bearer YOUR_TOKEN"` |
| 141 | +- Make sure to include "Bearer " prefix in the header value |
| 142 | +- Check the HTTP HEADERS panel is properly formatted JSON |
| 143 | + |
| 144 | +### GraphQL Playground: Schema introspection failed |
| 145 | +- Ensure the application is running: `npm run start:dev` |
| 146 | +- Check `src/app.module.ts` has `playground: true` and `introspection: true` |
| 147 | +- Verify no enum or type errors in your GraphQL schema |
| 148 | + |
| 149 | +### Connection refused errors |
| 150 | +- Confirm the app is running on port 4005 |
| 151 | +- Check no other service is using port 4005 |
| 152 | +- Verify your `.env` file has correct configuration |
0 commit comments