web-chatter 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/web-chatter.js +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-chatter",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Simple Express-based web server for chat bots with user authentication, SQLite persistence per user, admin controls, and customizable authenticated routes",
5
5
  "main": "./web-chatter.js",
6
6
  "type": "module",
package/web-chatter.js CHANGED
@@ -21,8 +21,9 @@ export class WebChat {
21
21
  #dbDir;
22
22
 
23
23
  constructor(options = {}) {
24
+
24
25
  this.#options = {
25
- dbDir: path.join(process.cwd(), 'data'),
26
+ dbDir: path.join(process.cwd(), './data'),
26
27
  sessionSecret: 'super-secret-key-CHANGE-ME-12345',
27
28
  port: 3000,
28
29
  host: '0.0.0.0',
@@ -31,6 +32,8 @@ export class WebChat {
31
32
  trustAuth: ['127.0.0.1', '::1', 'localhost'],
32
33
  ...options,
33
34
  };
35
+
36
+
34
37
 
35
38
  this.#options.trustAuth = this.#options.trustAuth.map(ip => {
36
39
  if (ip === 'localhost') return ['127.0.0.1', '::1'];
@@ -52,7 +55,7 @@ export class WebChat {
52
55
  }
53
56
 
54
57
  #initUsersDatabase() {
55
- const usersDbPath = path.join(this.#dbDir, 'users.db');
58
+ const usersDbPath = path.join(dbDir, './__users_');
56
59
  this.#usersDb = new Database(usersDbPath, { verbose: console.log });
57
60
 
58
61
  this.#usersDb.exec(`
@@ -69,7 +72,7 @@ export class WebChat {
69
72
 
70
73
  #getUserDb(username) {
71
74
  const safeUsername = username.replace(/[^a-zA-Z0-9_-]/g, '_');
72
- const userDbPath = path.join(this.#dbDir, `chat-${safeUsername}.db`);
75
+ const userDbPath = path.join(this.#dbDir, `_wb_${safeUsername}_`);
73
76
  return new Database(userDbPath, { verbose: console.log });
74
77
  }
75
78
 
@@ -511,7 +514,7 @@ export class WebChat {
511
514
  // ──────────────────────────────────────────────────────────────
512
515
 
513
516
  const safeUsername = target.replace(/[^a-zA-Z0-9_-]/g, '_');
514
- const userDbPath = path.join(this.#dbDir, `chat-${safeUsername}.db`);
517
+ const userDbPath = path.join(this.#dbDir, `_wb_${safeUsername}_`);
515
518
  if (fs.existsSync(userDbPath)) {
516
519
  try {
517
520
  fs.unlinkSync(userDbPath);
@@ -534,8 +537,7 @@ export class WebChat {
534
537
  console.log(
535
538
  `WebChat server listening on http://${host === '0.0.0.0' ? 'localhost' : host}:${port}`
536
539
  );
537
- console.log(`Users DB: ${path.join(this.#dbDir, 'users.db')}`);
538
- console.log(`User chat DBs in: ${this.#dbDir}`);
540
+ console.log(`DBs in: ${this.#dbDir}`);
539
541
  if (this.#options.trustAuth?.length) {
540
542
  console.log(`Trusted IPs: ${this.#options.trustAuth.join(', ')}`);
541
543
  }