@blurpaper/shared 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/paper-configuration.class.d.ts +11 -0
- package/dist/classes/paper-configuration.class.js +45 -0
- package/dist/classes/url-formatter.class.d.ts +4 -0
- package/dist/classes/url-formatter.class.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/env.interface.d.ts +16 -0
- package/dist/interfaces/env.interface.js +2 -0
- package/package.json +1 -1
- package/tsconfig.json +0 -11
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IEnv } from "../interfaces/env.interface";
|
|
2
|
+
export declare class PaperConfiguration {
|
|
3
|
+
env: IEnv;
|
|
4
|
+
isProduction: boolean;
|
|
5
|
+
app: any;
|
|
6
|
+
https: any;
|
|
7
|
+
fs: any;
|
|
8
|
+
constructor(env: IEnv, app: any, https: any, fs: any);
|
|
9
|
+
startNodeServer(): void;
|
|
10
|
+
getCorsOrigin(): Record<string, string | RegExp>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaperConfiguration = void 0;
|
|
4
|
+
class PaperConfiguration {
|
|
5
|
+
env;
|
|
6
|
+
isProduction;
|
|
7
|
+
app;
|
|
8
|
+
https;
|
|
9
|
+
fs;
|
|
10
|
+
constructor(env, app, https, fs) {
|
|
11
|
+
this.env = env;
|
|
12
|
+
this.isProduction = env.NODE_ENV === 'production';
|
|
13
|
+
this.app = app;
|
|
14
|
+
this.https = https;
|
|
15
|
+
this.fs = fs;
|
|
16
|
+
}
|
|
17
|
+
startNodeServer() {
|
|
18
|
+
let server = this.app;
|
|
19
|
+
if (this.isProduction && this.env.PRIVATE_KEY && this.env.FULL_CHAIN) {
|
|
20
|
+
try {
|
|
21
|
+
server = this.https.createServer({
|
|
22
|
+
key: this.fs.readFileSync(this.env.PRIVATE_KEY),
|
|
23
|
+
cert: this.fs.readFileSync(this.env.FULL_CHAIN),
|
|
24
|
+
rejectUnauthorized: false,
|
|
25
|
+
}, this.app);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.log('ERROR:');
|
|
29
|
+
console.log('Could not start with SSL connection');
|
|
30
|
+
console.log(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
server.listen(this.env.PORT, () => {
|
|
34
|
+
console.log(`${this.env.APP_NAME} is listening on port ${this.env.PORT}!!!!`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getCorsOrigin() {
|
|
38
|
+
return {
|
|
39
|
+
origin: this.isProduction ?
|
|
40
|
+
/^(https:\/\/)([a-zA-Z0-9\-]+)?(?!\/)(?!\?).?(blurpaper.com):?([0-9]+)?/ :
|
|
41
|
+
'*'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.PaperConfiguration = PaperConfiguration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.URLFormatter = void 0;
|
|
4
|
+
class URLFormatter {
|
|
5
|
+
url;
|
|
6
|
+
constructor(protocol, linkTo, port) {
|
|
7
|
+
this.url = `${protocol}://${linkTo}:${port}`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.URLFormatter = URLFormatter;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from "./interfaces/alphabet-settings-input.interface";
|
|
2
2
|
export * from "./interfaces/start-end.interface";
|
|
3
3
|
export * from "./interfaces/repetitable-data.interface";
|
|
4
|
+
export * from "./interfaces/env.interface";
|
|
4
5
|
export * from "./helpers/object.helper";
|
|
5
6
|
export * from "./helpers/string.helper";
|
|
6
7
|
export * from "./classes/key-alphabet.class";
|
|
8
|
+
export * from "./classes/paper-configuration.class";
|
|
9
|
+
export * from "./classes/url-formatter.class";
|
|
7
10
|
export * from "./enums/save-upload-file.enum";
|
|
8
11
|
export * from "./constants";
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./interfaces/alphabet-settings-input.interface"), exports);
|
|
18
18
|
__exportStar(require("./interfaces/start-end.interface"), exports);
|
|
19
19
|
__exportStar(require("./interfaces/repetitable-data.interface"), exports);
|
|
20
|
+
__exportStar(require("./interfaces/env.interface"), exports);
|
|
20
21
|
__exportStar(require("./helpers/object.helper"), exports);
|
|
21
22
|
__exportStar(require("./helpers/string.helper"), exports);
|
|
22
23
|
__exportStar(require("./classes/key-alphabet.class"), exports);
|
|
24
|
+
__exportStar(require("./classes/paper-configuration.class"), exports);
|
|
25
|
+
__exportStar(require("./classes/url-formatter.class"), exports);
|
|
23
26
|
__exportStar(require("./enums/save-upload-file.enum"), exports);
|
|
24
27
|
__exportStar(require("./constants"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface IEnv {
|
|
2
|
+
LINK_TO_PAPER_CRUD?: string;
|
|
3
|
+
LINK_TO_PAPER_LOOP?: string;
|
|
4
|
+
LINK_TO_PAPER_EMAIL_BE?: string;
|
|
5
|
+
LINK_TO_PAPER_EBOOK_REPO?: string;
|
|
6
|
+
PAPER_EBOOK_REPO_PORT?: number;
|
|
7
|
+
PAPER_CRUD_PORT?: string;
|
|
8
|
+
PAPER_LOOP_PORT?: string;
|
|
9
|
+
PAPER_EMAIL_BE_PORT?: number;
|
|
10
|
+
PROTOCOL?: string;
|
|
11
|
+
NODE_ENV?: string;
|
|
12
|
+
PRIVATE_KEY?: string;
|
|
13
|
+
FULL_CHAIN?: string;
|
|
14
|
+
APP_NAME?: string;
|
|
15
|
+
PORT?: string;
|
|
16
|
+
}
|
package/package.json
CHANGED