/vite-pouchdb

Primary LanguageJavaScript

⚡ vite-pouchdb

Adds a PouchDB server to Vite

ℹ️ Overview

Vite server middleware plugin for a CouchDB REST service using express-pouchdb. By default, the plugin mounts the PouchDB Server to /db/* on the development server.

🎉 Get Started

📦 Prerequisites

🔨 Install

cd my-amazing-vite-project
npm install vite-pouchdb pouchdb events

⚙️ Usage

🔧 Configuration

vite.config.js

import PouchDB from 'pouchdb'
import {pouchdb} from 'vite-pouchdb'
export default defineConfig({
  plugins: [pouchdb(
    PouchDB.defaults({prefix: './.data/'}),
  )],
});

index.html

Patch global in the browser for legacy packages

 <script>
    if(typeof global === 'undefined'){
      var global = global || window;
    }
  </script>

🚀 Running

Development Server

vite

🔀 PouchDB API

🕸️ REST Endpoint

curl http://localhost:5173/db
{
  "express-pouchdb": "Welcome!",
  "version": "4.2.0",
  "pouchdb-adapters": [
    "leveldb"
  ],
  "vendor": {
    "name": "PouchDB authors",
    "version": "4.2.0"
  },
  "uuid": "b8cdd23d-7e30-4223-97b7-7da53d3290e6"
}

💄 Fauxton UI