5htp-core 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "5-HTP, scientifically called 5-Hydroxytryptophan, is the precursor of happiness neurotransmitter.",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -37,6 +37,7 @@
37
37
  "fast-safe-stringify": "^2.1.1",
38
38
  "fs-extra": "^10.1.0",
39
39
  "google-auth-library": "^7.11.0",
40
+ "got": "^11.8.3",
40
41
  "handlebars": "^4.7.7",
41
42
  "helmet": "^4.6.0",
42
43
  "history": "^5.0.1",
@@ -73,7 +74,7 @@
73
74
  "validator": "^13.7.0",
74
75
  "ws": "^8.2.2",
75
76
  "yaml": "^1.10.2"
76
- },
77
+ },
77
78
  "devDependencies": {
78
79
  "@types/cookie": "^0.4.1",
79
80
  "@types/express": "^4.17.13",
@@ -35,23 +35,9 @@ export type TEnvConfig = {
35
35
  profile: 'dev' | 'prod',
36
36
  level: 'silly' | 'info' | 'warn' | 'error',
37
37
 
38
+ localIP: string,
38
39
  domain: string,
39
- protocol: 'http' | 'https',
40
- url: string, // protocol + domain
41
- localIP?: string
42
-
43
- http: {
44
- port: number,
45
- ssl: boolean
46
- },
47
-
48
- database: {
49
- host: string,
50
- port: number,
51
- login: string,
52
- password: string,
53
- list: string[]
54
- },
40
+ url: string,
55
41
  }
56
42
 
57
43
  type AppIdentityConfig = {
@@ -101,9 +87,27 @@ export default class ConfigParser {
101
87
  return yaml.parse(rawConfig);
102
88
  }
103
89
 
104
- public env() {
105
- const envFile = this.appDir + '/env' + (this.envName === undefined ? '' : '.' + this.envName) + '.yaml';
106
- return this.loadYaml( envFile );
90
+ public env(): TEnvConfig {
91
+ // We assume that when we run 5htp dev, we're in local
92
+ // Otherwise, we're in production environment (docker)
93
+ console.log("Using environment:", process.env.NODE_ENV);
94
+ return process.env.NODE_ENV === 'development' ? {
95
+ name: 'local',
96
+ profile: 'dev',
97
+ level: 'silly',
98
+
99
+ localIP: '86.76.176.80',
100
+ domain: 'localhost:3010',
101
+ url: 'http://localhost:3010',
102
+ } : {
103
+ name: 'server',
104
+ profile: 'prod',
105
+ level: 'silly',
106
+
107
+ localIP: '86.76.176.80',
108
+ domain: 'megacharger.io',
109
+ url: 'https://megacharger.io',
110
+ }
107
111
  }
108
112
 
109
113
  public identity() {
@@ -62,13 +62,15 @@ export default class FastDatabase {
62
62
 
63
63
  console.info(`Connecting to databases ...`);
64
64
 
65
+ const creds = this.config[ app.env.profile ];
66
+
65
67
  return await mysql.createPool({
66
68
 
67
69
  // Identification
68
- host: this.config.host,
69
- port: this.config.port,
70
- user: this.config.login,
71
- password: this.config.password,
70
+ host: creds.host,
71
+ port: creds.port,
72
+ user: creds.login,
73
+ password: creds.password,
72
74
  database: this.config.list[0],
73
75
 
74
76
  // Pool
@@ -106,7 +108,7 @@ export default class FastDatabase {
106
108
  let type = field.type;
107
109
  if (field.db) {
108
110
 
109
- // A revoir, car les infos passées peuvent être des alias
111
+ // TODO: A revoir, car les infos passées peuvent être des alias
110
112
 
111
113
  const db = this.tables[ field.db ];
112
114
  if (db === undefined) {
@@ -41,11 +41,19 @@ export type TInsertQueryOptions<TData extends TObjetDonnees = TObjetDonnees> = T
41
41
  ----------------------------------*/
42
42
 
43
43
  export type DatabaseServiceConfig = {
44
- host: string,
45
44
  list: string[],
46
- login: string,
47
- password: string,
48
- port: number
45
+ dev: {
46
+ host: string,
47
+ port: number,
48
+ login: string,
49
+ password: string,
50
+ },
51
+ prod: {
52
+ host: string,
53
+ port: number,
54
+ login: string,
55
+ password: string,
56
+ }
49
57
  }
50
58
 
51
59
  declare global {
@@ -89,7 +89,7 @@ export default class HttpServer {
89
89
 
90
90
  this.http = http.createServer(this.express);
91
91
 
92
- } else if ('ssh' in app.env) {
92
+ } /*else if ('ssh' in app.env) {
93
93
 
94
94
  const ssh = app.env.ssh;
95
95
 
@@ -102,7 +102,7 @@ export default class HttpServer {
102
102
  rejectUnauthorized: false
103
103
  }, this.express);
104
104
 
105
- } else
105
+ }*/ else
106
106
  throw new Error(`SSL was enabled, but no ssh config was specified in app.env (required to load ssl certificate files)`);
107
107
 
108
108
  // Start HTTP Server
@@ -34,9 +34,9 @@
34
34
  "@errors": ["./common/errors"],
35
35
  "@models": ["./common/models"],
36
36
 
37
- "react": ["../node_modules/preact/compat"],
38
- "react-dom": ["../node_modules/preact/compat"],
39
- "react/jsx-runtime": ["../node_modules/preact/jsx-runtime"]
37
+ "react": ["preact/compat"],
38
+ "react-dom": ["preact/compat"],
39
+ "react/jsx-runtime": ["preact/jsx-runtime"]
40
40
  },
41
41
  },
42
42
  "include": ["src"]