mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-29 12:50:59 +00:00
fix: double rate limits across the board (#3108)
* fix: sqlite auto create path if missing * fix: double rate limits across the board
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { basename, extname, join, resolve } from 'path';
|
||||
import { existsSync, mkdirSync, readFileSync } from 'fs';
|
||||
import { basename, dirname, extname, join, resolve } from 'path';
|
||||
import { createContext, runInContext } from 'vm';
|
||||
import type { IConfig } from '../../types';
|
||||
import { AbstractDatabaseClient, type WriteResult } from './DatabaseClient';
|
||||
@@ -102,6 +102,10 @@ export class SqliteDatabaseClient extends AbstractDatabaseClient {
|
||||
: (this.config.database?.path ?? ':memory:');
|
||||
const isNew = dbPath === ':memory:' || !existsSync(dbPath);
|
||||
|
||||
if (dbPath !== ':memory:') {
|
||||
mkdirSync(dirname(dbPath), { recursive: true });
|
||||
}
|
||||
|
||||
this.db = new Database(dbPath);
|
||||
|
||||
await this.runMigrations(isNew);
|
||||
|
||||
@@ -51,11 +51,11 @@ export class KVStoreDriver extends PuterDriver {
|
||||
// (no subscription resolution) is not given the tighter cap.
|
||||
readonly rateLimit: DriverRateLimitConfig = {
|
||||
default: {
|
||||
limit: 200,
|
||||
limit: 400,
|
||||
window: 10_000,
|
||||
bySubscription: {
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 200,
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 100,
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 400,
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 200,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -81,11 +81,11 @@ export class SubdomainDriver extends PuterDriver {
|
||||
// same shape — the three crud-q drivers share one envelope.
|
||||
readonly rateLimit: DriverRateLimitConfig = {
|
||||
default: {
|
||||
limit: 100,
|
||||
limit: 200,
|
||||
window: 10_000,
|
||||
bySubscription: {
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 100,
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 50,
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 200,
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 100,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -42,21 +42,21 @@ import type { DriverConcurrentConfig, DriverRateLimitConfig } from '../meta.js';
|
||||
|
||||
export const AI_RATE_LIMIT: DriverRateLimitConfig = {
|
||||
default: {
|
||||
limit: 100, // subscribed / paid tier
|
||||
limit: 200, // subscribed / paid tier
|
||||
window: 10_000,
|
||||
bySubscription: {
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 30, // verified registered user
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 20, // temp / anonymous-email user
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 60, // verified registered user
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 40, // temp / anonymous-email user
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const AI_CONCURRENT: DriverConcurrentConfig = {
|
||||
default: {
|
||||
limit: 10, // subscribed / paid tier
|
||||
limit: 20, // subscribed / paid tier
|
||||
bySubscription: {
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 3, // verified registered user
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 2, // temp / anonymous-email user
|
||||
[DEFAULT_FREE_SUBSCRIPTION]: 6, // verified registered user
|
||||
[DEFAULT_TEMP_SUBSCRIPTION]: 4, // temp / anonymous-email user
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user