create-marcapony-app 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-marcapony-app",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Scaffold a Marcapony app \u2014 a Worker backed by the Marcapony API, ready for `marcapony app link` and `marcapony app deploy`",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -19,7 +19,10 @@ export async function api<T>(path: string, init?: { method?: string; body?: unkn
19
19
  })
20
20
  const body = (await response.json().catch(() => ({}))) as { error?: string }
21
21
  if (!response.ok) {
22
- throw new ApiError(response.status, body.error ?? `Request failed with status ${response.status}`)
22
+ throw new ApiError(
23
+ response.status,
24
+ body.error ?? `Request failed with status ${response.status}`,
25
+ )
23
26
  }
24
27
  return body as T
25
28
  }
@@ -85,8 +85,8 @@ export function App() {
85
85
  <p className="muted">Signed in as {me.email}</p>
86
86
  {me.preview ? (
87
87
  <p className="notice">
88
- Preview: you are viewing this page as a customer. Bookings and cancellations are
89
- simulated and nothing is saved.
88
+ Preview: you are viewing this page as a customer. Bookings and cancellations are simulated
89
+ and nothing is saved.
90
90
  </p>
91
91
  ) : null}
92
92
  {error ? <p className="error">{error}</p> : null}
@@ -176,7 +176,12 @@ function BookingForm({ onBooked }: { onBooked: () => void }) {
176
176
  </label>
177
177
  <label>
178
178
  Notes (optional)
179
- <textarea rows={3} maxLength={500} value={notes} onChange={(e) => edit(setNotes)(e.target.value)} />
179
+ <textarea
180
+ rows={3}
181
+ maxLength={500}
182
+ value={notes}
183
+ onChange={(e) => edit(setNotes)(e.target.value)}
184
+ />
180
185
  </label>
181
186
  <button type="submit" disabled={busy}>
182
187
  {busy ? 'Booking…' : 'Book'}
@@ -55,7 +55,9 @@ async function cartFingerprint(quantities: Map<string, number>): Promise<string>
55
55
  .map(([id, quantity]) => `${id}:${quantity}`)
56
56
  .join(',')
57
57
  const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonical))
58
- return [...new Uint8Array(digest).slice(0, 8)].map((b) => b.toString(16).padStart(2, '0')).join('')
58
+ return [...new Uint8Array(digest).slice(0, 8)]
59
+ .map((b) => b.toString(16).padStart(2, '0'))
60
+ .join('')
59
61
  }
60
62
 
61
63
  app.get('/api/health', (c) => c.json({ ok: true }))
@@ -192,10 +194,19 @@ app.post('/api/checkout', async (c) => {
192
194
  // In test mode the link is only simulated: nothing was saved and there is
193
195
  // nothing to pay yet, so there is no payment page either.
194
196
  if (link.simulated) {
195
- return c.json({ amount, currency, payUrl: null, linkId: link.linkId ?? null, simulated: true }, 201)
197
+ return c.json(
198
+ { amount, currency, payUrl: null, linkId: link.linkId ?? null, simulated: true },
199
+ 201,
200
+ )
196
201
  }
197
202
  return c.json(
198
- { amount, currency: link.currency, payUrl: link.paymentUrl, linkId: link.linkId, simulated: false },
203
+ {
204
+ amount,
205
+ currency: link.currency,
206
+ payUrl: link.paymentUrl,
207
+ linkId: link.linkId,
208
+ simulated: false,
209
+ },
199
210
  201,
200
211
  )
201
212
  })
@@ -101,7 +101,11 @@ app.post('/api/reservations/:id/status', async (c) => {
101
101
  return c.json({ error: 'status must be approved, rejected, cancelled or completed.' }, 400)
102
102
  }
103
103
  const input: UpdateReservationStatusInput = { status }
104
- if (status === 'rejected' && typeof body.rejectionReason === 'string' && body.rejectionReason.trim()) {
104
+ if (
105
+ status === 'rejected' &&
106
+ typeof body.rejectionReason === 'string' &&
107
+ body.rejectionReason.trim()
108
+ ) {
105
109
  input.rejectionReason = body.rejectionReason.trim().slice(0, 500)
106
110
  }
107
111