Skip to content

Commit eb154b8

Browse files
committed
Clean commit
0 parents  commit eb154b8

31 files changed

+4555
-0
lines changed

.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PORT=
2+
DOMAIN=""
3+
SERVER_DOMAIN=""
4+
ASSETS_DIR=""
5+
REQUEST_RECEIVER=""
6+
SECRET_KEY=""
7+
REFRESH_KEY=""
8+
REFRESH_LIFESPAN = '1y'
9+
TOKEN_LIFESPAN = '1h'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

AWS/Config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var config = {
2+
accessKeyId: '',
3+
secretAccessKey: '',
4+
region: '',
5+
};
6+
7+
module.exports = config;
8+

Client.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports =
2+
class Client {
3+
constructor(userid, username, type, socket){
4+
this.userid = userid;
5+
this.username = username;
6+
this.type = type;
7+
this.socket = socket;
8+
}
9+
10+
SetUserID(userid){
11+
this.userid = userid;
12+
}
13+
14+
SetUserName(username){
15+
this.username = username;
16+
}
17+
18+
SetSocket(socket){
19+
this.socket = socket;
20+
}
21+
22+
}

Database/Config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var config = {
2+
host: "",
3+
user: "",
4+
password: "",
5+
database: "",
6+
};
7+
8+
module.exports = config;

Database/DBConnect.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var mysql = require("mysql");
2+
var config = require("./Config.js");
3+
4+
var connection = mysql.createConnection(config);
5+
6+
module.exports = connection;

Database/Database.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const mysql = require("mysql");
2+
var config = require("./Config.js");
3+
4+
module.exports = class Database {
5+
constructor() {
6+
this.connection = mysql.createConnection(config);
7+
}
8+
9+
query(sql, args) {
10+
return new Promise((resolve, reject) => {
11+
this.connection.query(sql, args, (err, rows) => {
12+
if (err) return reject(err);
13+
resolve(rows);
14+
});
15+
});
16+
}
17+
18+
close() {
19+
return new Promise((resolve, reject) => {
20+
this.connection.end((err) => {
21+
if (err) return reject(err);
22+
resolve();
23+
});
24+
});
25+
}
26+
27+
static Execute(callback) {
28+
const database = new Database();
29+
return callback(database).then(
30+
(result) => database.close().then(() => result),
31+
(err) =>
32+
database.close().then(() => {
33+
throw err;
34+
})
35+
);
36+
}
37+
};

0 commit comments

Comments
 (0)