Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions driver-adapters-wasm/neon-netlify-basic-edgefn/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Local Netlify folder
.netlify

node_modules
netlify/edge-functions/prisma

*/.DS_Store

.vscode
60 changes: 60 additions & 0 deletions driver-adapters-wasm/neon-netlify-basic-edgefn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
![Netlify examples](https://user-images.githubusercontent.com/5865/159468750-df1c2783-39b2-40da-9c0f-971f72a7ea3f.png)

# [Netlify Edge Functions](https://www.netlify.com/products/?utm_campaign=devex&utm_source=edge-functions-examples&utm_medium=github&utm_content=Edge%20Functions%20Product%20Page#netlify-edge-functions) Examples

Explore these examples here: https://edge-functions-examples.netlify.app/

## Responses

- [Hello, world](/pages/hello)
- [Return JSON](/pages/json)
- [Return an image](/pages/image)

## Rewrites and proxies

- [Rewrite responses from another URL](/pages/rewrite)
- [Proxy requests to another source](/pages/proxy-requests)

## HTTP Headers

- [Set custom HTTP request headers](/pages/set-request-header)
- [Set custom HTTP response headers](/pages/set-response-header)

## Transforming responses

- [HTML transformation](/pages/htmlrewriter)
- [Text transformation](/pages/transform)
- [Content includes](/pages/include)

## Geolocation

- [Determine a user's location](/pages/geolocation)
- [Block content according to country](/pages/country-block)
- [Serve localized content](/pages/localized-content)

## Cookies

- [Set cookies](/pages/cookies-set)
- [Read cookies](/pages/cookies-read)
- [Delete cookies](/pages/cookies-delete)
- [Set up an A/B test using cookies](/pages/abtest)

## Streams
- [Long-running edge functions](/pages/long-running)
- [Server-sent events](/pages/server-sent-events)

## WebAssembly
- [Edge WebAssembly](/pages/wasm)

## Environment and debugging

- [Write to the logs](/pages/log)
- [Use environment variables](/pages/environment)

---

## Deploy this site to Netlify

Click this button to deploy this site automatically to your Netlify account.

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/netlify/edge-functions-examples&utm_campaign=devex&utm_source=edge-functions-examples&utm_medium=web&utm_content=Deploy%20Edge%20Functions%20Examples%20to%20Netlify)
5 changes: 5 additions & 0 deletions driver-adapters-wasm/neon-netlify-basic-edgefn/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[dev]
base = "./driver-adapters-wasm/neon-netlify-basic-edgefn"

[build]
command = "echo No build for this site, we are living on the edge"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createRequire } from "node:module";
const { PrismaClient } = createRequire(import.meta.url)("./prisma/client/edge");
import { PrismaNeon } from "npm:@prisma/adapter-neon"
import { Pool } from 'npm:@neondatabase/serverless'

const client = new Pool({ connectionString: "postgresql://mills:[email protected]/mydb?sslmode=require" })
const adapter = new PrismaNeon(client)
const prisma = new PrismaClient({ adapter })

export default async (request, context) => {
const data = await prisma.user.findMany({});

return Response.json(JSON.stringify(data));
};

export const config = {
path: "/json",
};
27 changes: 27 additions & 0 deletions driver-adapters-wasm/neon-netlify-basic-edgefn/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "edge-functions-examples",
"description": "Explore a library of reference examples for learning about Edge Functions on Netlify.",
"version": "1.0.0",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/netlify/edge-functions-examples.git"
},
"keywords": [],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/netlify/edge-functions-examples/issues"
},
"homepage": "https://github.com/netlify/edge-functions-examples#readme",
"devDependencies": {
"netlify-cli": "^17.9.0",
"@prisma/client": "5.7.0-dev.80",
"prisma": "5.7.0-dev.80"
},
"dependencies": {
"@neondatabase/serverless": "0.6.0",
"@prisma/adapter-neon": "5.7.0-dev.80",
"@prisma/client": "5.7.0-dev.80"
}
}
Loading