Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrobenolt committed Oct 19, 2023
1 parent 1848375 commit e506f4b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -6,7 +6,7 @@ COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go install -v github.com/mattrobenolt/ps-http-sim
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags "-s -w" -trimpath -v github.com/mattrobenolt/ps-http-sim

FROM scratch
COPY --from=build /go/bin/ps-http-sim /ps-http-sim
Expand Down
40 changes: 40 additions & 0 deletions README.md
@@ -0,0 +1,40 @@
# ps-http-sim

`ps-http-sim` stands in as a proxy in front of a normal MySQL database, and provides a PlanetScale HTTP API compatibility layer.

At the moment, this is not an official PlanetScale project, and is in early stage development and quality. Please do not use this in production environments.

This is intended to aid when adopting `@planetscale/database` in your application and wanting to run against a local database.

# Usage

```
$ ps-http-sim -help
Usage of ps-http-sim:
-listen-addr string
HTTP server address (default "127.0.0.1")
-listen-port uint
HTTP server port (default 8080)
-mysql-addr string
MySQL address (default "127.0.0.1")
-mysql-dbname string
MySQL database to connect to (default "mysql")
-mysql-idle-timeout duration
MySQL connection idle timeout (default 10s)
-mysql-max-rows uint
Max rows for a single query result set (default 1000)
-mysql-no-pass
Don't use password for MySQL connection
-mysql-port uint
MySQL port (default 3306)
```

There is an example Node configuration in the `example/` folder.

## Authentication

The authentication you configure in your database-js application, is passed along as-is to your local MySQL database. So you'd want to match up the authentication to match what you'd with a normal MySQL client.

If your database is configured to not use a password, the `-mysql-no-pass` flag must be set on `ps-http-sim`, but database-js must be configured still to send a password. The password may be anything except blank.

This is a bit of a "wart" in that the PlanetScale API would fail if not being presented with a password at all since it's impossible to have a PlanetScale database without a password.

0 comments on commit e506f4b

Please sign in to comment.