tspace-mysql
Version:
Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.
70 lines • 2.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Package = void 0;
class Package {
static import(name) {
try {
return require(name);
}
catch (err) {
throw new Error(`The package '${name}' caused by '${err.message}'. Please try installing the package using : npm install ${name} --save`);
}
}
static get fs() {
try {
const fs = require('fs');
return {
existsSync: (v) => fs.existsSync(v),
writeFileSync: (path, data, options = {}) => fs.writeFileSync(path, data, options),
readdirSync: (path, options = { withFileTypes: false }) => fs.readdirSync(path, options),
readFileSync: (path, encoding) => fs.readFileSync(path, encoding)
};
}
catch (err) {
throw new Error(`The package 'fs' is not supported. Please ensure you are running in a Node.js environment.`);
}
}
static get path() {
try {
const path = require('path');
return {
join: (...paths) => path.join(...paths),
resolve: (...paths) => {
return paths == null || !paths.length
? path.resolve()
: path.resolve(...paths);
}
};
}
catch (err) {
throw new Error(`The package 'path' is not supported. Please ensure you are running in a Node.js environment.`);
}
}
static get dotenv() {
try {
const dotenv = require('dotenv');
return {
config: (options = {}) => dotenv.config(options),
};
}
catch (err) {
throw new Error(`The package 'dotenv' caused by '${err.message}'. Please try installing the package using : npm install dotenv --save`);
}
}
static get redis() {
try {
const redis = require('redis'); // redis@5.6.0+
return {
createClient: ({ url, socket }) => {
return redis.createClient({ url, socket });
}
};
}
catch (err) {
throw new Error(`The package 'redis' caused by '${err.message}'. Please try installing the package using : npm install redis@5.6.0 --save`);
}
}
}
exports.Package = Package;
exports.default = Package;
//# sourceMappingURL=Package.js.map