[PR #55] [MERGED] Attach to an existing server. Route prefixing (#49) #55

Closed
opened 2026-05-23 08:39:36 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/appy-one/acebase-server/pull/55
Author: @Azarattum
Created: 11/24/2022
Status: Merged
Merged: 12/5/2022
Merged by: @appy-one

Base: masterHead: server


📝 Commits (5)

  • d80668b add option to use an external server
  • 86df890 add route prefix option
  • 7934988 refactor requested changed
  • a9c6df3 fix backwards compatibility
  • ae5ded4 change route config option to rootPath

📊 Changes

6 files changed (+77 additions, -15 deletions)

View changed files

📝 src/routes/webmanager.ts (+1 -1)
📝 src/server.ts (+48 -14)
📝 src/settings/index.ts (+18 -0)
📝 src/shared/env.ts (+1 -0)
📝 src/shared/http.ts (+8 -0)
📝 src/websocket/socket.io.ts (+1 -0)

📄 Description

Some changes that were discussed in #49 were made here. I added a server option that accepts an http server and a route option which overrides the base route for AceBase.

For example (modified test.ts):

// Starts a test server for debugging sessions
import { createServer } from 'http';
import { AceBaseServer } from './server';

// Make sure development environment is set
process.env.NODE_ENV = 'development';

const server = createServer();
server.listen(8080);

const base = new AceBaseServer('default', { logLevel: 'verbose', route: '/acebase', host: 'localhost', port: 8080, server, path: '.' });
base.once('ready', () => {
    console.log(`Ready to debug!`);
});

process.on("SIGINT", () => server.close());

It will use server as it's server and listen on http://localhost:8080/acebase. Socket.IO will listen on http://localhost:8080/acebase/ws.

IMPORTANT! BREAKING CHANGE!

The default path for socket.io is now http://localhost:8080/ws! (Previously was http://localhost:8080/socket.io). In general the path now is http://localhost:8080/ + route + /ws.

AceBase didn't specify any path before for Socket.IO to use, therefore it fellback to /socket.io. We might want to change the new version to http://localhost:8080/ + route + /socket.io to preserve compatibility. But since this PR needs client changes anyway I thought using ws would be nicer. Also I've seen some comments in the code about supporting other web socket libraries. I that case /ws would be more future proof path than /socket.io.

I haven't started working on the client yet. Let me know you thoughts about this PR. What shall we do with socket.io? Are the other changes ok? I've also fixed the redirect to webmanager. Are there any other path dependent parts that I might have missed?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/appy-one/acebase-server/pull/55 **Author:** [@Azarattum](https://github.com/Azarattum) **Created:** 11/24/2022 **Status:** ✅ Merged **Merged:** 12/5/2022 **Merged by:** [@appy-one](https://github.com/appy-one) **Base:** `master` ← **Head:** `server` --- ### 📝 Commits (5) - [`d80668b`](https://github.com/appy-one/acebase-server/commit/d80668b339940a98d0a29e59ed1fc42b564b3c53) add option to use an external server - [`86df890`](https://github.com/appy-one/acebase-server/commit/86df89052a321b625400d5f742021c56b93c3e65) add route prefix option - [`7934988`](https://github.com/appy-one/acebase-server/commit/79349880aeb22acb77600ce8a30a44827a971e28) refactor requested changed - [`a9c6df3`](https://github.com/appy-one/acebase-server/commit/a9c6df3c00b83eddfb36b1d8fccb49f700c99613) fix backwards compatibility - [`ae5ded4`](https://github.com/appy-one/acebase-server/commit/ae5ded4da2b44f5b69e326ad457d1a2aa8776e53) change route config option to rootPath ### 📊 Changes **6 files changed** (+77 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src/routes/webmanager.ts` (+1 -1) 📝 `src/server.ts` (+48 -14) 📝 `src/settings/index.ts` (+18 -0) 📝 `src/shared/env.ts` (+1 -0) 📝 `src/shared/http.ts` (+8 -0) 📝 `src/websocket/socket.io.ts` (+1 -0) </details> ### 📄 Description Some changes that were discussed in #49 were made here. I added a `server` option that accepts an `http` server and a `route` option which overrides the base route for AceBase. For example (modified `test.ts`): ```ts // Starts a test server for debugging sessions import { createServer } from 'http'; import { AceBaseServer } from './server'; // Make sure development environment is set process.env.NODE_ENV = 'development'; const server = createServer(); server.listen(8080); const base = new AceBaseServer('default', { logLevel: 'verbose', route: '/acebase', host: 'localhost', port: 8080, server, path: '.' }); base.once('ready', () => { console.log(`Ready to debug!`); }); process.on("SIGINT", () => server.close()); ``` It will use `server` as it's server and listen on `http://localhost:8080/acebase`. Socket.IO will listen on `http://localhost:8080/acebase/ws`. ## IMPORTANT! BREAKING CHANGE! The default path for socket.io is now `http://localhost:8080/ws`! (Previously was `http://localhost:8080/socket.io`). In general the path now is `http://localhost:8080/` + **route** + `/ws`. AceBase didn't specify any path before for `Socket.IO` to use, therefore it fellback to `/socket.io`. We might want to change the new version to `http://localhost:8080/` + **route** + `/socket.io` to preserve compatibility. But since this PR needs client changes anyway I thought using `ws` would be nicer. Also I've seen some comments in the code about supporting other web socket libraries. I that case `/ws` would be more future proof path than `/socket.io`. I haven't started working on the client yet. Let me know you thoughts about this PR. What shall we do with `socket.io`? Are the other changes ok? I've also fixed the redirect to `webmanager`. Are there any other path dependent parts that I might have missed? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-23 08:39:36 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-server#55
No description provided.