Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c0ba2ac

Browse files
committed
Fix src titles and format code snippets
1 parent 57e2109 commit c0ba2ac

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

docs/guides/nodejs/survey-application.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ cd surveys-backend
4141
npm install
4242
```
4343

44+
You can now delete all files in the services/ folder, we'll create new services in this guide.
45+
4446
## Add Runtime Type Safety
4547

4648
This project uses:
4749

4850
- [Zod](https://zod.dev/) to define and validate the structure of form submissions.
49-
- [pdfkit](https://pdfkit.org/) to generate pdfs from html templates.
51+
- [pdfkit](https://pdfkit.org/) to generate PDFs from html templates.
5052

5153
### Install Zod
5254

@@ -56,7 +58,7 @@ npm install zod pdfkit
5658

5759
### Define a schema for form submissions
5860

59-
Create a file at `src/forms/form/schema.ts`:
61+
Create a file at `form/schema.ts`:
6062

6163
```ts title:src/forms/form/schema.ts
6264
import { z } from 'zod'
@@ -76,7 +78,7 @@ This schema ensures that any incoming submission contains a valid name, a 1–5
7678
7779
Create and configure the cloud resources your backend will use, such as storage buckets, queues, and key-value stores.
7880
79-
```ts title:src/resources/resources.ts
81+
```ts title:resources/resources.ts
8082
import { bucket, kv, topic } from '@nitric/sdk'
8183

8284
export const output = bucket('receipts').allow('read', 'write')
@@ -89,10 +91,10 @@ export const receipts = topic('form-submitted')
8991

9092
Create an API route that validates and stores form submissions, then triggers further processing.
9193

92-
```ts title:src/services/forms.ts
94+
```ts title:services/forms.ts
9395
import { api } from '@nitric/sdk'
9496
import { submissions, submitted } from '../resources/resources'
95-
import { SubmissionSchema } from '.../forms/form/schema'
97+
import { SubmissionSchema } from '../form/schema'
9698

9799
const formApi = api('forms')
98100

@@ -118,9 +120,9 @@ formApi.post('/forms/:formId', async (ctx) => {
118120

119121
Listen for submitted events and generate a formatted PDF receipt from the stored data.
120122

121-
```ts title:src/services/pdfs.ts
123+
```ts title:services/pdfs.ts
122124
import { receipts, submissions, output } from '../resources/resources'
123-
import { buildReceipt } from '../forms/form/receipt'
125+
import { buildReceipt } from '../form/receipt'
124126

125127
receipts.subscribe(async (ctx) => {
126128
const { id } = ctx.req.json()
@@ -144,7 +146,7 @@ receipts.subscribe(async (ctx) => {
144146

145147
### Build the PDF Receipt
146148

147-
```ts title:src/forms/form/receipt.ts
149+
```ts title:form/receipt.ts
148150
import PDFDocument from 'pdfkit'
149151
import { Submission } from './schema'
150152

@@ -198,7 +200,7 @@ This PDF output is fairly plain, you can enhance it further using layout templat
198200

199201
Simulate or perform delivery of the receipt (e.g. via email or other downstream systems).
200202

201-
```ts title:src/services/deliver.ts
203+
```ts title:services/deliver.ts
202204
import { receipts } from '../resources/resources'
203205

204206
receipts.subscribe(async (ctx) => {
@@ -213,7 +215,7 @@ receipts.subscribe(async (ctx) => {
213215

214216
Create an endpoint that returns a download URL for the generated receipt file.
215217

216-
```ts title:src/apis/receipts.ts
218+
```ts title:services/receipts.ts
217219
import { api } from '@nitric/sdk'
218220
import { output } from '../resources/resources'
219221

0 commit comments

Comments
 (0)