Comments (3)
The only way is to rethink the way you do data storage using encryption and permission Middleware
from minimongo.
Or you can provide your own httpClient
passing CORS options like credentials: 'include'
, then implement session-based HTTP proxy to your database.
from minimongo.
This entire project is client side code. You cannot trust anything happening here, so this is not just about exposing an url or connection id. (I wonder how you do want to hide anything browser related to a user)
What I did is implement proper security (authentication via JWT basically and authorisation on collections and their methods) on the server side. That is the service hosting the API minimongo is talking to.
Then, because I'm using Angular, I hat to write a tiny wrapper so minimongo is using my httpClient, which is configured to send cookies to the api-server.
My client sode code looks somewhat like this, though I additionally have an interceptor that sets the withCredentials options for every outgoing http request to my backends.
import * as minimongo from 'minimongo';
// This is just a loggin helper to get started.
const log = (name: string) => ((...args: any[]) => console.log(name, args));
// Setup local, remote and hybrid database
const IndexedDb = new minimongo.IndexedDb({}, log('IndexedDb success'), log('IndexedDb error'));
const RemoteDb = new minimongo.RemoteDb('https://url.to.my.backend/api/');
const HybridDb = new minimongo.HybridDb(IndexedDb, RemoteDb);
// My data service
@Injectable({
providedIn: 'root'
})
export class FoobarDataService {
constructor(
private http: HttpClient,
) {
// Mimic the interface that minimongo expects.
const httpClient = (method: string, url: string, params: any, body: any, success: () => any, error: () => any) => {
this.http.request(method, url, { body: body, params: params }).subscribe(success, error);
};
RemoteDb.httpClient = httpClient;
IndexedDb.addCollection('foobar', log('IndexedDb.addCollection success'), log('IndexedDb.addCollection error'));
RemoteDb.addCollection('foobar', {}, log('RemoteDb.addCollection success'), log('RemoteDb.addCollection error'));
HybridDb.addCollection('foobar', log('HybridDb.addCollection success'), log('HybridDb.addCollection error'));
}
}
from minimongo.
Related Issues (20)
- How update data locally?? HOT 5
- Promise version? HOT 8
- how to connect the mongodb server? HOT 1
- replication MONGODB HOT 5
- Add Support for $text operator HOT 1
- High Vulnerability - Prototype Polution update to Lodash 4.17.11
- Does it support react native? HOT 1
- upsert on HybridDB HOT 2
- Cannot read property 'findOne' of undefined with HybridDB HOT 6
- Support CORS? HOT 2
- Where is this function : EJSON.newBinary ?
- [docs] Specify that `client` arg is required for Hybrid use HOT 1
- Does minimongo implement reactivity HOT 2
- Comparission to https://pouchdb.com/ HOT 1
- Key $v must not start with '$' HOT 1
- ⚠️ Web SQL is deprecated HOT 1
- Improvement on RemoteDb docs HOT 7
- db.collection.remove doesn't actually remove the data from indexedDB? HOT 1
- So how do you open an existing db? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minimongo.