Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: circular dependencies #3081

Merged
merged 9 commits into from
Nov 13, 2024
38 changes: 16 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,32 @@

const SqlString = require('sqlstring');

const Connection = require('./lib/connection.js');
const ConnectionConfig = require('./lib/connection_config.js');
const parserCache = require('./lib/parsers/parser_cache');
const parserCache = require('./lib/parsers/parser_cache.js');

exports.createConnection = function(opts) {
return new Connection({ config: new ConnectionConfig(opts) });
};
const Connection = require('./lib/connection.js');

exports.createConnection = require('./lib/create_connection.js');
exports.connect = exports.createConnection;
exports.Connection = Connection;
exports.ConnectionConfig = ConnectionConfig;

const Pool = require('./lib/pool.js');
const PoolCluster = require('./lib/pool_cluster.js');
const createPool = require('./lib/create_pool.js');
const createPoolCluster = require('./lib/create_pool_cluster.js');

exports.createPool = function(config) {
const PoolConfig = require('./lib/pool_config.js');
return new Pool({ config: new PoolConfig(config) });
};
exports.createPool = createPool;

exports.createPoolCluster = function(config) {
const PoolCluster = require('./lib/pool_cluster.js');
return new PoolCluster(config);
};
exports.createPoolCluster = createPoolCluster;

exports.createQuery = Connection.createQuery;

exports.Pool = Pool;

exports.PoolCluster = PoolCluster;

exports.createServer = function(handler) {
exports.createServer = function (handler) {
const Server = require('./lib/server.js');
const s = new Server();
if (handler) {
Expand All @@ -42,7 +36,7 @@ exports.createServer = function(handler) {
return s;
};

exports.PoolConnection = require('./lib/pool_connection');
exports.PoolConnection = require('./lib/pool_connection.js');
exports.authPlugins = require('./lib/auth_plugins');
exports.escape = SqlString.escape;
exports.escapeId = SqlString.escapeId;
Expand All @@ -51,33 +45,33 @@ exports.raw = SqlString.raw;

exports.__defineGetter__(
'createConnectionPromise',
() => require('./promise.js').createConnection
() => require('./promise.js').createConnection,
);

exports.__defineGetter__(
'createPoolPromise',
() => require('./promise.js').createPool
() => require('./promise.js').createPool,
);

exports.__defineGetter__(
'createPoolClusterPromise',
() => require('./promise.js').createPoolCluster
() => require('./promise.js').createPoolCluster,
);

exports.__defineGetter__('Types', () => require('./lib/constants/types.js'));

exports.__defineGetter__('Charsets', () =>
require('./lib/constants/charsets.js')
require('./lib/constants/charsets.js'),
);

exports.__defineGetter__('CharsetToEncoding', () =>
require('./lib/constants/charset_encodings.js')
require('./lib/constants/charset_encodings.js'),
);

exports.setMaxParserCache = function(max) {
exports.setMaxParserCache = function (max) {
parserCache.setMaxCache(max);
};

exports.clearParserCache = function() {
exports.clearParserCache = function () {
parserCache.clearCache();
};
Loading
Loading