diff --git a/README.md b/README.md index 0f9dd7f..965d42b 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ # neon-vercel-zapatos -This repo demonstrates the use of [Zapatos](https://jawj.github.io/zapatos/) with [Neon's serverless driver](https://www.npmjs.com/package/@neondatabase/serverless) on [Vercel](https://vercel.com/) Edge Functions. +This repo demonstrates the use of [Zapatos](https://jawj.github.io/zapatos/) with [Neon](https://www.npmjs.com/package/@neondatabase/serverless) on [Vercel](https://vercel.com/) Edge Functions. -We implement a simple app that generates a JSON listing of the user's nearest 10 UNESCO World Heritage sites via IP geolocation (data copyright © 1992 – 2022 [UNESCO/World Heritage Centre](https://whc.unesco.org/en/syndication/)). +It is a simple app that generates a JSON listing of the user's nearest 10 UNESCO World Heritage sites via IP geolocation (data copyright © 1992 – 2022 [UNESCO/World Heritage Centre](https://whc.unesco.org/en/syndication/)). ## How it works The `@neondatabase/serverless` driver is compatible with (and built on top of) [node-postgres](https://node-postgres.com/), the `pg` package. But because Zapatos tries to import the `pg` package directly, we have a small amount of extra work to do. -First, we include a tiny [local-path package](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#local-paths), which you'll find in `shims/pg`. This calls itself `pg` but simply re-exports the contents of `@neondatabase/serverless`. That makes Zapatos work in a serverless environment. +1. Copy `shims/pg` and create a local-path [[1]]( https://docs.npmjs.com/cli/v9/configuring-npm/package-json#local-paths) entry in `package.json`. This re-exports `@neondatabase/serverless` as `pg` as that's what Zapatos needs. -Second, we generate and update the Zapatos schema types (inside `./zapatos`) at development-time using Node, by running `npm run update-zapatos-types`. Because Node has no native `WebSocket` object, this calls a simple custom script, `update-zapatos-types.mjs`, in which we configure the serverless driver to use the `ws` package. +2. Generate Zapatos schema types by running `npm run update-zapatos-types`. Because Node has no native `WebSocket` object, this calls a simple custom script, `update-zapatos-types.mjs`, in which we configure the serverless driver to use the `ws` package. -Third, it's important to set `"strict": true` and add `"zapatos/**/*"` to the `"include"` directive in `tsconfig.json`. +3. It's important to set `"strict": true` and add `"zapatos/**/*"` to the `"include"` directive in `tsconfig.json`. ## Deploy