Skip to content

Instantly share code, notes, and snippets.

@twilson63
Created March 13, 2018 00:16
Show Gist options
  • Save twilson63/c96491be435dc5bb74916305f9f7a1f8 to your computer and use it in GitHub Desktop.
Save twilson63/c96491be435dc5bb74916305f9f7a1f8 to your computer and use it in GitHub Desktop.
Pouchdb Server with MySQL Backend

PouchDB Server using a MySQL Backend

PouchDB server is a nodejs implementation of CouchDB. Below is the steps to use AmazonRDS and NowJS to deploy your own PouchDB Server. Using MySQL as a persistent backend.

Amazon Web Services

Create a Amazon Web Services Account

https://aws.amazon.com

Use aws console to create an Amazon RDS MySQL Instance

https://console.aws.amazon.com/rds/home?region=us-east-1#

Follow the step by step directions make sure you capture the following information

endpoint: ... username: root password: ...

Zeit Now

npm i now -g
mkdir [servername]
cd [servername]
npm i json -g
yarn init -y 
yarn add pouchdb-server @twilson63/mysql-down  
json -I -f package.json -e 'this.scripts = {"start": "pouchdb-server --level-backend=@twilson63/mysql-down"}'

create a new file called .env

MYSQL_URI=mysql://[username]:[password]@[endpoint]:3306/[dbname]
MYSQL_SSL=Amazon RDS

create a new file called config.json

{
  "couchdb": {
    "uuid": "unique-string"
  }, 
  "log": {
    "file": "/tmp/logs.txt"
  }
}

Deploy to Now

URL=$(now -E)
now alias ${URL} [servername].[domain]

Verify Pouchdb and Setup Admin

Fin

@fdenzer
Copy link

fdenzer commented Jan 30, 2019

What does your now.json look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment