mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-23 06:26:55 +00:00
fix: dbConfigs and ai routes (#2868)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
* fix: db configs Co-authored-by: Copilot <copilot@github.com> * fix: ai routes Co-authored-by: Copilot <copilot@github.com> --------- Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
co-authored by
Copilot
parent
0e53edafa3
commit
f6e1f90225
@@ -60,7 +60,7 @@ export class MySQLDatabaseClient extends AbstractDatabaseClient {
|
||||
});
|
||||
console.log('[mysql] connected to primary');
|
||||
|
||||
this.db = new SQLBatcher(this.primaryPool, 40, 10);
|
||||
this.db = new SQLBatcher(this.primaryPool, 30, 5);
|
||||
|
||||
if (dbConf.replica) {
|
||||
this.replicaPool = this.createPool(dbConf.replica);
|
||||
@@ -71,7 +71,7 @@ export class MySQLDatabaseClient extends AbstractDatabaseClient {
|
||||
this.configuration = Configuration.SINGLE;
|
||||
}
|
||||
|
||||
this.dbReplica = new SQLBatcher(this.replicaPool, 10, 10);
|
||||
this.dbReplica = new SQLBatcher(this.replicaPool, 10, 5);
|
||||
}
|
||||
|
||||
override async onServerPrepareShutdown(): Promise<void> {
|
||||
@@ -201,6 +201,7 @@ export class MySQLDatabaseClient extends AbstractDatabaseClient {
|
||||
private createPool(poolConfig: PoolConfig): Pool {
|
||||
return createPool({
|
||||
maxPreparedStatements: 900,
|
||||
connectionLimit: 30,
|
||||
...poolConfig,
|
||||
multipleStatements: true,
|
||||
} as PoolConfig);
|
||||
@@ -219,11 +220,11 @@ export class MySQLDatabaseClient extends AbstractDatabaseClient {
|
||||
password: dbConf.password ?? '',
|
||||
database: dbConf.database ?? 'puter',
|
||||
});
|
||||
this.db = new SQLBatcher(this.primaryPool, 40, 10);
|
||||
this.db = new SQLBatcher(this.primaryPool, 30, 5);
|
||||
|
||||
if (this.configuration === Configuration.SINGLE) {
|
||||
this.replicaPool = this.primaryPool;
|
||||
this.dbReplica = new SQLBatcher(this.primaryPool, 10, 10);
|
||||
this.dbReplica = new SQLBatcher(this.primaryPool, 10, 5);
|
||||
}
|
||||
|
||||
if (previous && previous !== this.primaryPool) {
|
||||
@@ -237,7 +238,7 @@ export class MySQLDatabaseClient extends AbstractDatabaseClient {
|
||||
|
||||
const previous = this.replicaPool;
|
||||
this.replicaPool = this.createPool(this.config.database.replica);
|
||||
this.dbReplica = new SQLBatcher(this.replicaPool, 10);
|
||||
this.dbReplica = new SQLBatcher(this.replicaPool, 10, 5);
|
||||
|
||||
if (
|
||||
previous &&
|
||||
|
||||
@@ -30,56 +30,61 @@ const GEMINI_DOWNLOAD_BASE =
|
||||
*/
|
||||
export class PuterAIController extends PuterController {
|
||||
registerRoutes(router: PuterRouter): void {
|
||||
const apiOpts = { subdomain: 'api', requireAuth: true } as const;
|
||||
const apiAuthOpts = { subdomain: 'api', requireAuth: true } as const;
|
||||
const publicOpts = { subdomain: 'api', requireAuth: false } as const;
|
||||
|
||||
// Every route below carries the `/puterai` prefix for wire
|
||||
// compatibility with puter-js and existing API tests.
|
||||
router.post(
|
||||
'/puterai/openai/v1/chat/completions',
|
||||
apiOpts,
|
||||
apiAuthOpts,
|
||||
this.openaiChatCompletions,
|
||||
);
|
||||
router.post(
|
||||
'/puterai/openai/v1/completions',
|
||||
apiOpts,
|
||||
apiAuthOpts,
|
||||
this.openaiCompletions,
|
||||
);
|
||||
router.post(
|
||||
'/puterai/openai/v1/responses',
|
||||
apiOpts,
|
||||
apiAuthOpts,
|
||||
this.openaiResponses,
|
||||
);
|
||||
router.post(
|
||||
'/puterai/anthropic/v1/messages',
|
||||
apiOpts,
|
||||
apiAuthOpts,
|
||||
this.anthropicMessages,
|
||||
);
|
||||
|
||||
// Model listing — enumerate available models per AI service
|
||||
router.get('/puterai/chat/models', apiOpts, this.#listModels('aiChat'));
|
||||
router.get(
|
||||
'/puterai/chat/models',
|
||||
publicOpts,
|
||||
this.#listModels('aiChat'),
|
||||
);
|
||||
router.get(
|
||||
'/puterai/chat/models/details',
|
||||
apiOpts,
|
||||
publicOpts,
|
||||
this.#modelDetails('aiChat'),
|
||||
);
|
||||
router.get(
|
||||
'/puterai/image/models',
|
||||
apiOpts,
|
||||
publicOpts,
|
||||
this.#listModels('aiImage'),
|
||||
);
|
||||
router.get(
|
||||
'/puterai/image/models/details',
|
||||
apiOpts,
|
||||
publicOpts,
|
||||
this.#modelDetails('aiImage'),
|
||||
);
|
||||
router.get(
|
||||
'/puterai/video/models',
|
||||
apiOpts,
|
||||
publicOpts,
|
||||
this.#listModels('aiVideo'),
|
||||
);
|
||||
router.get(
|
||||
'/puterai/video/models/details',
|
||||
apiOpts,
|
||||
publicOpts,
|
||||
this.#modelDetails('aiVideo'),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user