many fixes

This commit is contained in:
Mia 2021-11-25 17:17:57 -06:00
parent 06ca90694f
commit 7e0a9d62d6
4 changed files with 13 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
node_modules
.dist
.eslintcache
config/config.js
config/*

7
config/pm2-example.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
apps: [{
name: "loginserver",
script: "./.dist/src",
exec_mode: "cluster",
}],
};

View File

@ -7,10 +7,10 @@
"scripts": {
"lint": "eslint . --cache --ext .js,.ts",
"build": "npx tsc",
"start": "npx tsc && npx pm2 start ./.dist/src --name loginserver --time",
"start": "npx tsc && npx pm2 start config/pm2.js",
"test": "npm run lint && npx tsc",
"reload": "npx tsc && npx pm2 reload loginserver",
"stop": "npx pm2 stop loginserver"
"reload": "npx tsc && npx pm2 reload config/pm2.js",
"stop": "npx pm2 stop config/pm2.js"
},
"dependencies": {
"@types/node": "^15.12.4",

View File

@ -15,13 +15,12 @@ export const databases: PSDatabase[] = [];
export class PSDatabase {
pool: mysql.Pool;
prefix: string;
constructor(config: {[k: string]: any} = Config.mysql, prefix?: string) {
constructor(config: {[k: string]: any} = {...Config.mysql}) {
this.prefix = config.prefix || "";
if (config.prefix) {
prefix = config.prefix;
delete config.prefix;
}
this.pool = mysql.createPool(config);
this.prefix = prefix || "";
if (!databases.includes(this)) databases.push(this);
}
query<T = ResultRow>(query: SQLStatement) {