Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b8e39c0
feat(api): add /sleep/recent and /sleep/range list endpoints with val…
ebigunso Aug 21, 2025
1b97684
feat(ui): dashboard week view, SleepBar, SleepForm with duration warn…
ebigunso Aug 21, 2025
cc689eb
test(ui): add Playwright e2e flow and Vitest unit tests for SleepBar …
ebigunso Aug 21, 2025
53407dc
:art: Format
ebigunso Aug 21, 2025
39de558
:bug: Fix to have tests pass
ebigunso Aug 21, 2025
5ce9220
:adhesive_bandage: Fix warnings
ebigunso Aug 21, 2025
da2f9f3
:bug: Fixes
ebigunso Aug 22, 2025
147f971
api: move routes to /api/* (login/logout/sleep/exercise/note/health);…
ebigunso Aug 22, 2025
26f4921
ui: call backend under /api; update api.ts, SleepForm note to /api/no…
ebigunso Aug 22, 2025
1ab1b9d
docs/spec/tests: align everything to /api/* routes; update OpenAPI an…
ebigunso Aug 22, 2025
791ed69
ui: logout via /api/logout; remove dev-only /auth usage everywhere
ebigunso Aug 22, 2025
411455f
:bug: Dashboard week fix
ebigunso Aug 22, 2025
6f83a82
ui(api): narrow Json to Record<string, unknown> | unknown[] and…
ebigunso Aug 22, 2025
b9a60d6
ui(test): replace deprecated String.prototype.substr with substring i…
ebigunso Aug 22, 2025
6fc9975
ui(edit): strongly type apiGet on edit page with SleepListItem instea…
ebigunso Aug 22, 2025
dc4d788
repository: fix WHERE alias bug in list_sleep_range (use wake_date in…
ebigunso Aug 22, 2025
57c43ec
feat(api): add GET /api/sleep/{id} and /api/exercise/intensity; valid…
ebigunso Aug 22, 2025
48e2dcf
:zap: Exersise input
ebigunso Aug 23, 2025
ee60452
feat(ui): add SSR load for sleep edit page
ebigunso Aug 23, 2025
fb860a0
refactor(ui): use load data in /sleep/[id]/edit and remove client-sid…
ebigunso Aug 23, 2025
95ef35a
:art: Fromat
ebigunso Aug 23, 2025
982a75d
chore(api): fix clippy warnings by removing unused imports in app router
ebigunso Aug 23, 2025
544f9cf
fix(api): explicitly register GET/PUT/DELETE for /api/sleep/{id} to r…
ebigunso Aug 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api_examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```bash
curl -X POST http://localhost:8080/sleep \
curl -X POST http://localhost:8080/api/sleep \
-H "Content-Type: application/json" \
-d '{"date":"2025-06-17","bed_time":"23:05","wake_time":"06:15","latency_min":10,"awakenings":1,"quality":4}'
```
196 changes: 186 additions & 10 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Sleep API
version: '0.1'
paths:
/login:
/api/login:
post:
summary: Login (form)
description: Issues session and CSRF cookies via Set-Cookie. Send subsequent mutating requests with X-CSRF-Token equal to the CSRF cookie value.
Expand All @@ -22,7 +22,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/login.json:
/api/login.json:
post:
summary: Login (JSON)
deprecated: true
Expand All @@ -43,7 +43,7 @@ paths:
properties:
ok:
type: boolean
/logout:
/api/logout:
post:
summary: Logout
security:
Expand All @@ -64,7 +64,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/health:
/api/health:
get:
responses:
'200':
Expand All @@ -89,7 +89,7 @@ paths:
authenticated:
type: boolean

/sleep:
/api/sleep:
post:
requestBody:
required: true
Expand Down Expand Up @@ -122,7 +122,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/sleep/date/{date}:
/api/sleep/date/{date}:
get:
parameters:
- in: path
Expand All @@ -147,7 +147,30 @@ paths:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
/sleep/{id}:
/api/sleep/{id}:
get:
parameters:
- in: path
name: id
schema:
type: integer
security:
- cookieAuth: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/SleepSession'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
put:
parameters:
- in: path
Expand Down Expand Up @@ -202,7 +225,80 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/exercise:
/api/sleep/recent:
get:
summary: Recent daily sleep entries
parameters:
- in: query
name: days
required: false
schema:
type: integer
minimum: 1
maximum: 31
security:
- cookieAuth: []
responses:
'200':
description: Up to N recent entries ordered desc by date
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SleepListItem'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequest'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/sleep/range:
get:
summary: Daily sleep entries within an inclusive date range
parameters:
- in: query
name: from
required: true
schema:
type: string
format: date
- in: query
name: to
required: true
schema:
type: string
format: date
security:
- cookieAuth: []
responses:
'200':
description: Entries in range ordered asc by date
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SleepListItem'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequest'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/exercise:
post:
requestBody:
required: true
Expand Down Expand Up @@ -235,7 +331,46 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
/note:
/api/exercise/intensity:
get:
summary: Exercise intensity by date in range
parameters:
- in: query
name: from
required: true
schema:
type: string
format: date
- in: query
name: to
required: true
schema:
type: string
format: date
security:
- cookieAuth: []
responses:
'200':
description: Intensities ordered asc by date
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/DateIntensity'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequest'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/note:
post:
requestBody:
required: true
Expand Down Expand Up @@ -443,6 +578,15 @@ components:
duration_min:
type: integer
nullable: true
DateIntensity:
type: object
properties:
date:
type: string
format: date
intensity:
type: string
enum: [none, light, hard]
NoteInput:
type: object
properties:
Expand All @@ -462,8 +606,40 @@ components:
Error:
type: object
properties:
error:
code:
type: string
message:
type: string
detail:
type: string
nullable: true
SleepListItem:
type: object
properties:
id:
type: integer
date:
type: string
format: date
bed_time:
type: string
format: time
wake_time:
type: string
format: time
latency_min:
type: integer
awakenings:
type: integer
quality:
type: integer
duration_min:
type: integer
nullable: true
BadRequest:
type: object
properties:
code:
type: string
message:
type: string
Loading