Adds a PouchDB server to Vite
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.
- node.js ^14.18.0 || >=16.0.0
- vite project ^4.3.2
cd my-amazing-vite-project
npm install vite-pouchdb pouchdb events
import PouchDB from 'pouchdb'
import {pouchdb} from 'vite-pouchdb'
export default defineConfig({
plugins: [pouchdb(
PouchDB.defaults({prefix: './.data/'}),
)],
});
Patch
global
in the browser for legacy packages
<script>
if(typeof global === 'undefined'){
var global = global || window;
}
</script>
vite
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"
}