# Features — lambdaNodejsPdf

Evidence date: 2026-10-10.

Source: `git@bitbucket.org:overdrive/lambdanodejspdf.git`, `master` at `012edf2` (2021-09-30).

"Current" means declared in `serverless.yml` or executed by a handler that file points at. There is no issue tracker or roadmap in the repository, so nothing is marked planned unless a comment describes behaviour the code does not perform.

## Current features

### F-01 — GET text to PDF

`GET /api/pdf` → `handler.generate_pdf`.

Reads query parameter `text`. Falls back to `Hello world` when that property is falsy. Draws it with PDFKit 0.12.3. Returns HTTP 200, `Content-Type: application/pdf`, base64 body, `isBase64Encoded: true`.

If the request has no query string, `event.queryStringParameters` is null and the handler throws before the fallback.

Origin: `c651a1a` added the handler and the route. `ee231d5` changed the YAML handler from `handler.pdf` to `handler.generate_pdf`.

Status: **current**. Confidence: high.

Source: `handler.js`, `serverless.yml`.

### F-02 — POST HTML to PDF and S3

`POST /api/htmltopdf` → `htmltopdf.main`. Memory 1024 MB in `serverless.yml`.

Parses a JSON body. Fields: `data` (required), `filename` (optional), `pagesize` (optional, default `a4`). Writes a PDF under `/tmp` through the `wkhtmltopdf` 0.4.0 wrapper and calls `S3.putObject` on bucket `pmf-invoices`.

The function calls `callback`, which is not defined, and it does not await the conversion. The success value `{ filename }` is not an API Gateway response. The packaged zip does not include a `wkhtmltopdf` binary. The execution role in the committed template has no S3 write.

Origin: `012edf2` ("new hk html to pdf function"). The comment's sample HTML is `<h1>Claudemiro</h1>`. That string is an example in a comment.

Status: **current** as a deployed route in the update template, and **incomplete** as a handler. Confidence: high.

Source: `htmltopdf.js`, `config.js`, `serverless.yml`, `.serverless/cloudformation-template-update-stack.json`.

### F-03 — Shared logging helper for the HTML route

`config.js` constructs a `hewer` 0.4.0 logger with a one-line formatter: level, message, then `JSON.stringify` of the meta object. `htmltopdf.js` logs the variables, the missing-data case, the S3 error, and a successful upload message.

`handler.js` does not use this logger.

The same file sets `process.env.PATH` to `PATH` plus `LAMBDA_TASK_ROOT` so a binary in the task root would be found. The zip root has no such binary.

Status: **current**. Confidence: high.

Source: `config.js`.

### F-04 — Open HTTP API

API name `dev-lambdanodepdf`, protocol HTTP, stage `$default`, auto-deploy, payload format 2.0. No authorizer and no CORS block.

Both functions share role `lambdanodepdf-dev-{region}-lambdaRole`. The inline policy allows `logs:CreateLogGroup`, `logs:CreateLogStream`, and `logs:PutLogEvents` on `/aws/lambda/lambdanodepdf-dev*`.

Status: **current** in the committed template. Confidence: high. Whether the live stack still matches this template is **Unknown**.

Source: `.serverless/cloudformation-template-update-stack.json`.

### F-05 — Individual function packages committed to git

`package.individually: true`. Git tracks `generate-pdf.zip` and `generate-htmltopdf.zip`. At `012edf2` each zip has 4554 entries and the same root files: `.npmignore`, `config.js`, `handler.js`, `htmltopdf.js`, `package-lock.json`, and `node_modules`. Both Lambda versions in the update template share one `CodeSha256` (`Ay/g36TLP5lMvdA+YKx1CDoi+S9qZNpZ3KBwg2W7qQg=`).

Status: **current**. Confidence: high.

## Changed features

| Change | From | To | Commit |
|---|---|---|---|
| PDF route handler string | `handler.pdf` | `handler.generate_pdf` | `ee231d5` |
| Second route | none | `POST /api/htmltopdf` | `012edf2` |
| PDF function artifact | zip without `htmltopdf.js` (about 10,159,099 bytes at `ee231d5`) | zip that includes `htmltopdf.js` and `config.js` (about 10,630,834 bytes) | `012edf2` |

`handler.js` itself is unchanged after `c651a1a`. The export was `generate_pdf` from the first version of that file. For the commits `c651a1a` only, the YAML name did not match the export.

## Not deployed / not a product feature

| Item | Evidence | Status |
|---|---|---|
| `package.json` | Not in any commit | Absent. Install metadata is the lockfile plus `require()` |
| Tests, README, CI | Not in any commit | Absent |
| `sonar-project.properties`, `sonarqube_scan.bat` | Named on the onboarding issue's file list | Not in git history |
| Lambda layer or a `wkhtmltopdf` binary | `layers: {}` in Serverless state. Zip listing has `node_modules/wkhtmltopdf/index.js`, `package.json`, and `README.md` only for that package | Not packaged |
| `aws-sdk` dependency pin | `require('aws-sdk')` in `htmltopdf.js`. No `aws-sdk` entry in `package-lock.json` | Relies on the Lambda Node 12 runtime SDK. **Inferred** |
| Authorizer, API key, VPC, custom domain | Not in `serverless.yml` or the update template | Absent |

## Planned features

None. No TODO, roadmap, or comment describes a feature the code does not already attempt.

## Deprecated / removed features

No route has been removed. The string `handler.pdf` existed in YAML for two commits and never had a matching export. It is not a removed feature; it was a handler-name mismatch, corrected in `ee231d5`.

## Recently changed

The newest behaviour is F-02, commit `012edf2` on 2021-09-30. No commit since then is on `origin/master`.
