Skip to content

Commit 5ce1952

Browse files
adds file upload endpoint
1 parent 83bba78 commit 5ce1952

File tree

4 files changed

+384
-8
lines changed

4 files changed

+384
-8
lines changed

apps/pdf-analyzer-service/api/openapi.yaml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,158 @@ paths:
2525
commit:
2626
type: string
2727
example: local-dev
28+
/v1/uploads:
29+
post:
30+
summary: Upload a PDF to create an analysis job
31+
operationId: uploadPdf
32+
tags: [jobs]
33+
requestBody:
34+
required: true
35+
content:
36+
multipart/form-data:
37+
schema:
38+
type: object
39+
properties:
40+
file:
41+
type: string
42+
format: binary
43+
required: [file]
44+
responses:
45+
'201':
46+
description: Job created
47+
content:
48+
application/json:
49+
schema:
50+
type: object
51+
properties:
52+
jobId:
53+
type: string
54+
'400':
55+
description: Bad request
56+
content:
57+
application/json:
58+
schema:
59+
type: object
60+
properties:
61+
error:
62+
type: string
63+
/v1/jobs:
64+
get:
65+
summary: List jobs
66+
operationId: listJobs
67+
tags: [jobs]
68+
responses:
69+
'200':
70+
description: List of jobs
71+
content:
72+
application/json:
73+
schema:
74+
type: object
75+
properties:
76+
jobs:
77+
type: array
78+
items:
79+
type: object
80+
properties:
81+
id:
82+
type: string
83+
status:
84+
type: string
85+
enum: [queued, processing, completed, failed]
86+
createdAt:
87+
type: string
88+
format: date-time
89+
updatedAt:
90+
type: string
91+
format: date-time
92+
/v1/jobs/{id}:
93+
get:
94+
summary: Get job by id
95+
operationId: getJob
96+
tags: [jobs]
97+
parameters:
98+
- in: path
99+
name: id
100+
required: true
101+
schema:
102+
type: string
103+
responses:
104+
'200':
105+
description: Job details
106+
content:
107+
application/json:
108+
schema:
109+
type: object
110+
properties:
111+
id:
112+
type: string
113+
status:
114+
type: string
115+
enum: [queued, processing, completed, failed]
116+
filePath:
117+
type: string
118+
originalName:
119+
type: string
120+
createdAt:
121+
type: string
122+
format: date-time
123+
updatedAt:
124+
type: string
125+
format: date-time
126+
error:
127+
type: string
128+
result:
129+
nullable: true
130+
'404':
131+
description: Not found
132+
content:
133+
application/json:
134+
schema:
135+
type: object
136+
properties:
137+
error:
138+
type: string
139+
/v1/jobs/{id}/complete:
140+
post:
141+
summary: Mark job as completed or failed (called by worker)
142+
operationId: completeJob
143+
tags: [jobs]
144+
parameters:
145+
- in: path
146+
name: id
147+
required: true
148+
schema:
149+
type: string
150+
requestBody:
151+
required: false
152+
content:
153+
application/json:
154+
schema:
155+
type: object
156+
properties:
157+
status:
158+
type: string
159+
enum: [completed, failed]
160+
result:
161+
nullable: true
162+
error:
163+
type: string
164+
responses:
165+
'200':
166+
description: Updated
167+
content:
168+
application/json:
169+
schema:
170+
type: object
171+
properties:
172+
ok:
173+
type: boolean
174+
'404':
175+
description: Not found
176+
content:
177+
application/json:
178+
schema:
179+
type: object
180+
properties:
181+
error:
182+
type: string

apps/pdf-analyzer-service/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
"dependencies": {
1212
"express": "^4.19.2",
1313
"js-yaml": "^4.1.0",
14-
"swagger-ui-express": "^5.0.1"
14+
"multer": "^2.0.2",
15+
"swagger-ui-express": "^5.0.1",
16+
"uuid": "^9.0.1"
1517
},
1618
"devDependencies": {
19+
"@types/multer": "^2.0.0",
1720
"@types/express": "^4.17.21",
18-
"@types/node": "^22.7.4",
1921
"@types/js-yaml": "^4.0.9",
22+
"@types/node": "^22.7.4",
2023
"@types/swagger-ui-express": "^4.1.7",
2124
"tsx": "^4.19.1",
2225
"typescript": "^5.6.3"

0 commit comments

Comments
 (0)