You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1e6ee9c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,16 @@ Install the required dependencies:
49
49
pip install -r backend/requirements.txt
50
50
```
51
51
52
+
### Configure the JWT Signing Key
53
+
54
+
Create a local environment file for development and tests:
55
+
56
+
```powershell
57
+
Copy-Item .env.example .env
58
+
```
59
+
60
+
Generate a secret with `python -c "import secrets; print(secrets.token_urlsafe(48))"` and put it in `.env` as `JWT_SECRET_KEY`. The key must be at least 32 bytes. Keep `.env` private; it is ignored by Git.
61
+
52
62
### Sample Data (Optional, First Run Only)
53
63
54
64
To use the sample data, rename `backend/sample-data` to `backend/data`.
@@ -142,6 +152,14 @@ Move-Item backend/sample-data data
142
152
143
153
### Start the Application
144
154
155
+
Create the Docker environment file and generate a different secret from the local `.env` key:
156
+
157
+
```powershell
158
+
Copy-Item .env.docker.example .env.docker
159
+
```
160
+
161
+
Set `JWT_SECRET_KEY` in `.env.docker` to its own generated value. Compose passes this file into the container; it is ignored by Git and must be provided on the production host.
162
+
145
163
From the repository root, run:
146
164
147
165
```bash
@@ -174,6 +192,8 @@ On the startup screen, choose **Customer** to browse restaurants or **Restaurant
174
192
175
193
The API provides the following endpoints:
176
194
195
+
Customer login returns a bearer token. Include it in the `Authorization` header when calling the `/customers/me` and `/cart` endpoints.
196
+
177
197
| Method | Path | Description |
178
198
|---|---|---|
179
199
| GET |`/api/v1/health`|`Checks if the API is running.`|
@@ -186,6 +206,8 @@ The API provides the following endpoints:
186
206
| PATCH |`/api/v1/restaurants/{restaurant_id}/menu-items/{menu_item_id}`|`Updates a menu item's fields. Returns 200, 404 if the item or restaurant is not found, 422 for invalid input.`|
187
207
| DELETE |`/api/v1/restaurants/{restaurant_id}/menu-items/{menu_item_id}`|`Deletes a specific menu item. Returns 204 on success, 404 if not found.`|
188
208
| POST |`/api/v1/customers`|`Registers a customer. Returns 201 (without the password), 409 if the email is already registered, 422 for invalid input.`|
209
+
| POST |`/api/v1/login`|`Authenticates a customer and returns a bearer access token. Returns 200, 401 for invalid credentials or a deactivated account, 422 for invalid input.`|
210
+
| POST |`/api/v1/logout`|`Logs out a customer and invalidates their token`|
189
211
| GET |`/api/v1/customers/me`|`Returns the signed-in customer's info. Returns 401 if not signed in.`|
190
212
| PATCH |`/api/v1/customers/me`|`Updates the signed-in customer's name, email, telephone or delivery address. Returns 200, 401, 409 if the email is taken, 422 for invalid input.`|
191
213
| DELETE |`/api/v1/customers/me`|`Deactivates the signed-in customer's account (kept but marked inactive). Returns 204, 401 if not signed in.`|
0 commit comments