jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
446 stars 63 forks source link

Usage with serverless-offline #1

Closed MattNguyen closed 5 years ago

MattNguyen commented 5 years ago

Seems like this client could work nicely with serverless-offline as an interface to a local mysql instance.

How would you recommend using data api locally? Do you have any plans on supporting serverless-offline?

jeremydaly commented 5 years ago

Hi Matt,

I haven’t given much thought to an offline workflow. Since Data API doesn’t require connections from a VPC, you can call it directly when you run your application locally. However, since it’s just straight SQL (for the most part), it would be possible to have an “offline” mode that falls back to a standard mysql module connecting to localhost.

Thanks for the suggestion, Jeremy

matuella commented 5 years ago

This would be an awesome feature. I started to develop something similar to an offline interface. I was wondering between some viable approaches:

I really like it working alongside SLS offline, but it would not work for people that aren't using the serverless framework, thus IMO the last two options are what I'm most inclined to create.

What do you guys think?

davegariepy commented 5 years ago

@matuella serverless plugin seems cool

andreasbhansen commented 5 years ago

However, since it’s just straight SQL (for the most part), it would be possible to have an “offline” mode that falls back to a standard mysql module connecting to localhost.

Has this been given any more thought, also without the use of the Serverless framework? A fallback to a regular MySQL instance would definitely enhance the developer experience of working with Aurora Serverless.

cinqi commented 5 years ago

There is a project that can be used to do local Data API development, project can be found here: https://github.com/koxudaxi/local-data-api

However, this does not work out of the box with data-api-client. With the local-data-api you need to config AWS SDK to allow http endpoint, with the current data-api-client setup you'll get this error:

NetworkingError: Protocol "http:" not supported. Expected "https:"

I might open a PR for this to work, one workaround is to add a http: boolean parameter that can be used to allow localhost endpoint.

cinqi commented 5 years ago

PR created for this, https://github.com/jeremydaly/data-api-client/pull/26

jeremydaly commented 5 years ago

This was merged. Will release shortly.