Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Fix teplates dir resolve

Hakan Shehu14acf5dc8232
diff --git a/apps/server/src/services/job-service.ts b/apps/server/src/services/job-service.ts
index f03a2b6a..749d9f58 100644
--- a/apps/server/src/services/job-service.ts
+++ b/apps/server/src/services/job-service.ts
@@ -24,6 +24,10 @@ class JobService {
removeOnComplete: true,
},
});
+
+ this.jobQueue.on('error', (error) => {
+ console.error('Job queue error:', error);
+ });
}
public async initWorker() {
diff --git a/apps/server/src/services/rate-limit-service.ts b/apps/server/src/services/rate-limit-service.ts
index 10989d6e..38dcaa05 100644
--- a/apps/server/src/services/rate-limit-service.ts
+++ b/apps/server/src/services/rate-limit-service.ts
@@ -14,8 +14,7 @@ class RateLimitService {
};
public async isAuthIpRateLimitted(ip: string): Promise<boolean> {
- const rateLimitKey = this.buildKey(`ai_${ip}`);
- return await this.isRateLimited(rateLimitKey, {
+ return await this.isRateLimited(`ai_${ip}`, {
limit: 100,
window: 600, // 10 minutes
});
@@ -23,24 +22,21 @@ class RateLimitService {
public async isAuthEmailRateLimitted(email: string): Promise<boolean> {
const emailHash = sha256(email);
- const rateLimitKey = this.buildKey(`ae_${emailHash}`);
- return await this.isRateLimited(rateLimitKey, {
+ return await this.isRateLimited(`ae_${emailHash}`, {
limit: 10,
window: 600, // 10 minutes
});
}
public async isDeviceApiRateLimitted(deviceId: string): Promise<boolean> {
- const rateLimitKey = this.buildKey(`da_${deviceId}`);
- return await this.isRateLimited(rateLimitKey, {
+ return await this.isRateLimited(`da_${deviceId}`, {
limit: 100,
window: 60, // 1 minute
});
}
public async isDeviceSocketRateLimitted(deviceId: string): Promise<boolean> {
- const rateLimitKey = this.buildKey(`ds_${deviceId}`);
- return await this.isRateLimited(rateLimitKey, {
+ return await this.isRateLimited(`ds_${deviceId}`, {
limit: 20,
window: 60, // 1 minute
});
@@ -50,7 +46,7 @@ class RateLimitService {
key: string,
config: RateLimitConfig = this.defaultConfig
): Promise<boolean> {
- const redisKey = this.buildKey(key);
+ const redisKey = `rt_${key}`;
const attempts = await redis.incr(redisKey);
// Set expiry on first attempt
@@ -60,10 +56,6 @@ class RateLimitService {
return attempts > config.limit;
}
-
- private buildKey(key: string): string {
- return `rt_${key}`;
- }
}
export const rateLimitService = new RateLimitService();
diff --git a/apps/server/src/templates/index.ts b/apps/server/src/templates/index.ts
index c87feda8..be0dad05 100644
--- a/apps/server/src/templates/index.ts
+++ b/apps/server/src/templates/index.ts
@@ -1,7 +1,14 @@
import handlebars from 'handlebars';
import fs from 'fs';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+
+const templatesDir = path.join(__dirname, './');
export const emailVerifyTemplate = handlebars.compile(
- fs.readFileSync('./src/templates/email-verify.html', 'utf8')
+ fs.readFileSync(path.join(templatesDir, 'email-verify.html'), 'utf8')
);