mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 10:22:39 +01:00
🎨 rename Database -> db
This commit is contained in:
parent
81bfb4dbd2
commit
996878cbe3
1
.gitignore
vendored
1
.gitignore
vendored
@ -80,7 +80,6 @@ typings/
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
|
13
dist/Config.d.ts
vendored
Normal file
13
dist/Config.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import "missing-native-js-functions";
|
||||
declare const _default: {
|
||||
init: (opts?: DefaultOptions) => Promise<void>;
|
||||
getAll: () => DefaultOptions;
|
||||
setAll: (val: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
export interface DefaultOptions {
|
||||
api: any;
|
||||
gateway: any;
|
||||
voice: any;
|
||||
}
|
||||
export declare const DefaultOptions: DefaultOptions;
|
28
dist/Config.js
vendored
Normal file
28
dist/Config.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DefaultOptions = void 0;
|
||||
require("missing-native-js-functions");
|
||||
const Database_1 = __importDefault(require("./Database"));
|
||||
var Config;
|
||||
exports.default = {
|
||||
init: async function init(opts = exports.DefaultOptions) {
|
||||
Config = Database_1.default.data.config({}).cache();
|
||||
await Config.init();
|
||||
await Config.set(opts.merge(Config.cache || {}));
|
||||
},
|
||||
getAll: function get() {
|
||||
return Config.get();
|
||||
},
|
||||
setAll: function set(val) {
|
||||
return Config.set(val);
|
||||
},
|
||||
};
|
||||
exports.DefaultOptions = {
|
||||
api: {},
|
||||
gateway: {},
|
||||
voice: {},
|
||||
};
|
||||
//# sourceMappingURL=Config.js.map
|
1
dist/Config.js.map
vendored
Normal file
1
dist/Config.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AACrC,0DAA4B;AAE5B,IAAI,MAAqB,CAAC;AAE1B,kBAAe;IACd,IAAI,EAAE,KAAK,UAAU,IAAI,CAAC,OAAuB,sBAAc;QAC9D,MAAM,GAAG,kBAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,SAAS,GAAG;QACnB,OAAuB,MAAM,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,SAAS,GAAG,CAAC,GAAQ;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACD,CAAC;AAQW,QAAA,cAAc,GAAmB;IAC7C,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;CACT,CAAC"}
|
2
dist/Constants.d.ts
vendored
Normal file
2
dist/Constants.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { VerifyOptions } from "jsonwebtoken";
|
||||
export declare const JWTOptions: VerifyOptions;
|
5
dist/Constants.js
vendored
Normal file
5
dist/Constants.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JWTOptions = void 0;
|
||||
exports.JWTOptions = { algorithms: ["HS256"] };
|
||||
//# sourceMappingURL=Constants.js.map
|
1
dist/Constants.js.map
vendored
Normal file
1
dist/Constants.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAkB,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC"}
|
3
dist/Database.d.ts
vendored
Normal file
3
dist/Database.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { MongoDatabase } from "lambert-db";
|
||||
declare const db: MongoDatabase;
|
||||
export default db;
|
7
dist/Database.js
vendored
Normal file
7
dist/Database.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const lambert_db_1 = require("lambert-db");
|
||||
// TODO: load url from config
|
||||
const db = new lambert_db_1.MongoDatabase("mongodb://127.0.0.1:27017/lambert?readPreference=secondaryPreferred");
|
||||
exports.default = db;
|
||||
//# sourceMappingURL=Database.js.map
|
1
dist/Database.js.map
vendored
Normal file
1
dist/Database.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Database.js","sourceRoot":"","sources":["../src/Database.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAE3C,6BAA6B;AAC7B,MAAM,EAAE,GAAG,IAAI,0BAAa,CAAC,qEAAqE,CAAC,CAAC;AAEpG,kBAAe,EAAE,CAAC"}
|
1
dist/checkToken.d.ts
vendored
Normal file
1
dist/checkToken.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function checkToken(token: string): Promise<unknown>;
|
20
dist/checkToken.js
vendored
Normal file
20
dist/checkToken.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkToken = void 0;
|
||||
const Constants_1 = require("./Constants");
|
||||
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
||||
const Config_1 = __importDefault(require("./Config"));
|
||||
function checkToken(token) {
|
||||
return new Promise((res, rej) => {
|
||||
jsonwebtoken_1.default.verify(token, Config_1.default.getAll().api.security.jwtSecret, Constants_1.JWTOptions, (err, decoded) => {
|
||||
if (err || !decoded)
|
||||
return rej("Invalid Token");
|
||||
return res(decoded);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.checkToken = checkToken;
|
||||
//# sourceMappingURL=checkToken.js.map
|
1
dist/checkToken.js.map
vendored
Normal file
1
dist/checkToken.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"checkToken.js","sourceRoot":"","sources":["../src/checkToken.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAyC;AACzC,gEAA+B;AAC/B,sDAA8B;AAE9B,SAAgB,UAAU,CAAC,KAAa;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,sBAAU,EAAE,CAAC,GAAG,EAAE,OAAY,EAAE,EAAE;YAC3F,IAAI,GAAG,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,eAAe,CAAC,CAAC;YAEjD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"}
|
5
dist/index.d.ts
vendored
Normal file
5
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { checkToken } from "./checkToken";
|
||||
import Config, { DefaultOptions } from "./Config";
|
||||
import db from "./Database";
|
||||
import * as Constants from "./Constants";
|
||||
export { checkToken, Config, Constants, db, DefaultOptions };
|
35
dist/index.js
vendored
Normal file
35
dist/index.js
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DefaultOptions = exports.db = exports.Constants = exports.Config = exports.checkToken = void 0;
|
||||
const checkToken_1 = require("./checkToken");
|
||||
Object.defineProperty(exports, "checkToken", { enumerable: true, get: function () { return checkToken_1.checkToken; } });
|
||||
const Config_1 = __importStar(require("./Config"));
|
||||
exports.Config = Config_1.default;
|
||||
Object.defineProperty(exports, "DefaultOptions", { enumerable: true, get: function () { return Config_1.DefaultOptions; } });
|
||||
const Database_1 = __importDefault(require("./Database"));
|
||||
exports.db = Database_1.default;
|
||||
const Constants = __importStar(require("./Constants"));
|
||||
exports.Constants = Constants;
|
||||
//# sourceMappingURL=index.js.map
|
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAKjC,2FALA,uBAAU,OAKA;AAJnB,mDAAkD;AAI7B,iBAJd,gBAAM,CAIc;AAAiB,+FAJ3B,uBAAc,OAI2B;AAH1D,0DAA4B;AAGY,aAHjC,kBAAE,CAGiC;AAF1C,uDAAyC;AAEZ,8BAAS"}
|
@ -1,6 +1,6 @@
|
||||
import { checkToken } from "./checkToken";
|
||||
import Config, { DefaultOptions } from "./Config";
|
||||
import Database from "./Database";
|
||||
import db from "./Database";
|
||||
import * as Constants from "./Constants";
|
||||
|
||||
export { checkToken, Config, Constants, Database, DefaultOptions };
|
||||
export { checkToken, Config, Constants, db, DefaultOptions };
|
||||
|
Loading…
Reference in New Issue
Block a user