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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# PlanetScale Edge client
# PlanetScale database client

A JavaScript client for the PlanetScale Edge API.
A JavaScript client for PlanetScale databases.

## Installation

```
$ npm install @planetscale/edge
$ npm install @planetscale/database
```

## Usage

```ts
import { connect } from '@planetscale/edge'
import { connect } from '@planetscale/database'

const config = {
host: 'aws.connect.psdb.cloud',
Expand All @@ -29,7 +29,7 @@ console.log(results)
Use the `Client` connection factory class to create fresh connections for each transaction or web request handler.

```ts
import { Client } from '@planetscale/edge'
import { Client } from '@planetscale/database'

const client = new Client({
host: 'aws.connect.psdb.cloud',
Expand All @@ -49,7 +49,7 @@ Node.js version 18 includes a built-in global `fetch` function. When using an ol
[1]: https://github.com/nodejs/undici

```ts
import { connect } from '@planetscale/edge'
import { connect } from '@planetscale/database'
import { fetch } from 'undici'

const config = {
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@planetscale/edge",
"name": "@planetscale/database",
"version": "0.1.0",
"description": "A JavaScript client for communicating with PlanetScale Edge API.",
"description": "A JavaScript client for PlanetScale databases.",
"main": "dist/index.js",
"types": "dist/index.d.js",
"files": [
Expand Down Expand Up @@ -31,24 +31,23 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/planetscale/edge-js.git"
"url": "git+https://github.com/planetscale/database-js.git"
},
"keywords": [
"planetscale",
"database",
"mysql",
"vitess",
"edge",
"serverless",
"vercel",
"lambda"
],
"author": "PlanetScale",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/planetscale/edge-js/issues"
"url": "https://github.com/planetscale/database-js/issues"
},
"homepage": "https://github.com/planetscale/edge-js#readme",
"homepage": "https://github.com/planetscale/database-js#readme",
"dependencies": {
"sqlstring": ">=2.3.3"
},
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export class Connection {

private async postJSON<T>(url: string | URL, body = {}): Promise<T> {
const auth = btoa(`${this.config.username}:${this.config.password}`)
const response = await this.config.fetch(url.toString(), {
const { fetch } = this.config
const response = await fetch(url.toString(), {
method: 'POST',
body: JSON.stringify(body),
headers: {
Expand Down