Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple databases on the same port #1141

Closed
josiahruddell opened this issue May 21, 2019 · 6 comments
Closed

Allow multiple databases on the same port #1141

josiahruddell opened this issue May 21, 2019 · 6 comments

Comments

@josiahruddell
Copy link

josiahruddell commented May 21, 2019

Case

Enhancement

Issue

Cannot connect multiple databases to the same server/app running the same port through rxdb.

Info

  • Environment: Node.js
  • Adapter: All
  • Stack: Typescript

Code

const db1 = await DB.create({
  name: 'db1',
})

// add some collections to db1

const db2 = await DB.create({
  name: 'db2',
})

// add some collections to db2

Create a server on the nodeJS side...

db1.server({
  path: `/${db1}`,
  port: 3000,
})


db2.server({ // throws port in use
  path: `/${db2}`,
  port: 3000,
})

The feature request is to allow multiple calls to db.server with the same port and different paths.

@josiahruddell
Copy link
Author

I was looking through the code and would be happy to put up a PR but want to get the convo going here first.

@pubkey
Copy link
Owner

pubkey commented May 21, 2019

Hi @josiahruddell great idea.
I think we should make it possible to pass any express-instance when calling RxDatabase.server(). by this people could also run the rxdb-server and the rest-endpoint on the same port.

To serve two rxdb-databases on the same port, we could then do

const server1 = db1.server({
  path: `/${db1}`,
  port: 3000,
})


db2.server({
  path: `/${db2}`,
  express: server1.app
})

What do you think?

@josiahruddell
Copy link
Author

I like the implementation idea @pubkey. I'll take a stab at it soon.

@pubkey
Copy link
Owner

pubkey commented May 27, 2019

@josiahruddell have you started on this?
Coincidentally I also need this feature for my project. So I would implement it if you haven't.

@josiahruddell
Copy link
Author

Yeah I'll open a PR there are some TODOs still

@pubkey
Copy link
Owner

pubkey commented Aug 3, 2019

Closed see #1156 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants