@diagramers/cli 1.0.24 → 1.0.25
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/services/template-updater.d.ts +0 -1
- package/dist/services/template-updater.d.ts.map +1 -1
- package/dist/services/template-updater.js +2 -41
- package/dist/services/template-updater.js.map +1 -1
- package/package.json +1 -1
- package/templates/api/certs/auth-app-cert.json +0 -13
- package/templates/api/main.ts +0 -10
- package/templates/api/package.json +0 -70
- package/templates/api/src/assets/css/email-template.css +0 -8
- package/templates/api/src/assets/images/logo_large.png +0 -0
- package/templates/api/src/assets/keys/certificate.pem +0 -22
- package/templates/api/src/assets/keys/private-key.pem +0 -28
- package/templates/api/src/config/config-interface.ts +0 -191
- package/templates/api/src/config/development.ts +0 -145
- package/templates/api/src/config/index.ts +0 -59
- package/templates/api/src/config/production.ts +0 -145
- package/templates/api/src/config/staging.ts +0 -144
- package/templates/api/src/config/uat.ts +0 -144
- package/templates/api/src/controllers/account-controller.ts +0 -162
- package/templates/api/src/entities/audit.ts +0 -12
- package/templates/api/src/entities/base-entity.ts +0 -10
- package/templates/api/src/entities/user.ts +0 -71
- package/templates/api/src/helpers/FrameworkHelper.ts +0 -157
- package/templates/api/src/helpers/auth.ts +0 -971
- package/templates/api/src/helpers/cronHelper.ts +0 -170
- package/templates/api/src/helpers/dbcontext.ts +0 -83
- package/templates/api/src/helpers/encryptionHelper.ts +0 -76
- package/templates/api/src/helpers/enums.ts +0 -258
- package/templates/api/src/helpers/handle-response.ts +0 -49
- package/templates/api/src/helpers/httpHelper.ts +0 -75
- package/templates/api/src/helpers/mailer.ts +0 -152
- package/templates/api/src/helpers/result.ts +0 -47
- package/templates/api/src/helpers/string-helper.ts +0 -27
- package/templates/api/src/routes/account-routes.ts +0 -37
- package/templates/api/src/routes/auth-routes.ts +0 -286
- package/templates/api/src/routes/index.ts +0 -92
- package/templates/api/src/schemas/audit.ts +0 -36
- package/templates/api/src/schemas/otp.ts +0 -52
- package/templates/api/src/schemas/session.ts +0 -57
- package/templates/api/src/schemas/user.ts +0 -125
- package/templates/api/src/server/index.ts +0 -86
- package/templates/api/src/server/socket-server-provider.ts +0 -209
- package/templates/api/src/services/account-service.ts +0 -243
- package/templates/api/src/services/audit-service.ts +0 -56
- package/templates/api/tsconfig.json +0 -16
- package/templates/api/webpack.config.js +0 -66
@@ -1,59 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
import * as _ from 'lodash';
|
3
|
-
import { IConfig, IConfigProps, EnvironmentVariables } from './config-interface';
|
4
|
-
|
5
|
-
// Load environment variables
|
6
|
-
try {
|
7
|
-
require('dotenv').config();
|
8
|
-
} catch (error) {
|
9
|
-
console.warn('⚠️ dotenv not available, using system environment variables');
|
10
|
-
}
|
11
|
-
|
12
|
-
const env = process.env as EnvironmentVariables;
|
13
|
-
|
14
|
-
// Validate required environment variables
|
15
|
-
const validateEnvironment = () => {
|
16
|
-
const requiredVars = ['NODE_ENV'];
|
17
|
-
const missingVars = requiredVars.filter(varName => !env[varName]);
|
18
|
-
|
19
|
-
if (missingVars.length > 0) {
|
20
|
-
console.warn(`⚠️ Missing environment variables: ${missingVars.join(', ')}`);
|
21
|
-
console.warn(' Using default values. For production, set all required environment variables.');
|
22
|
-
}
|
23
|
-
};
|
24
|
-
|
25
|
-
const envConfig = () => {
|
26
|
-
const nodeEnv = env.NODE_ENV || 'development';
|
27
|
-
console.log(`🚀 Loading API with ${nodeEnv} configuration.`);
|
28
|
-
|
29
|
-
switch (nodeEnv) {
|
30
|
-
case "development": {
|
31
|
-
return require('./development');
|
32
|
-
}
|
33
|
-
case "staging": {
|
34
|
-
return require('./staging');
|
35
|
-
}
|
36
|
-
case "production": {
|
37
|
-
return require('./production');
|
38
|
-
}
|
39
|
-
default: {
|
40
|
-
console.warn(`⚠️ Unknown NODE_ENV: ${nodeEnv}. Using development configuration.`);
|
41
|
-
return require('./development');
|
42
|
-
}
|
43
|
-
}
|
44
|
-
};
|
45
|
-
|
46
|
-
export class Configuration {
|
47
|
-
constructor() {
|
48
|
-
validateEnvironment();
|
49
|
-
}
|
50
|
-
|
51
|
-
LoadConfiguration(): IConfig {
|
52
|
-
return {
|
53
|
-
variables: env,
|
54
|
-
props: envConfig()?.default || require('./development').default
|
55
|
-
};
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
export const Config = new Configuration().LoadConfiguration();
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import { WhatsappProviders, AuthProvider, OAuthProvider } from "../helpers/enums";
|
2
|
-
import { IConfigProps, WhatsappProvidersConfig, AuthConfig } from "./config-interface";
|
3
|
-
|
4
|
-
class Production implements IConfigProps {
|
5
|
-
isDev = false;
|
6
|
-
isProd = true;
|
7
|
-
host_name: string = 'https://api.sendifier.com';
|
8
|
-
port: string = process.env.PORT || '4000';
|
9
|
-
development_environment_url: 'https://humble-macaw-separately.ngrok-free.app'
|
10
|
-
database_connectionstring: string = "mongodb://system_user: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@184.72.123.229:27017/sendifier-production";
|
11
|
-
base_site_url: string = "https://app.sendifier.com";
|
12
|
-
register_complete_page_url: string = "register_complete";
|
13
|
-
whatsapp_default_provider: WhatsappProviders = WhatsappProviders.twilio;
|
14
|
-
whatsapp_providers_configurations = [{
|
15
|
-
key: WhatsappProviders.twilio,
|
16
|
-
value: {
|
17
|
-
provider_type: WhatsappProviders.twilio,
|
18
|
-
account_id: 'AC55b03a222fa486300e5791d8f34cfacd',
|
19
|
-
token: 'c3cc0022815391e027b7bf4bac47b46c'
|
20
|
-
}
|
21
|
-
}];
|
22
|
-
firebase_application_config = {
|
23
|
-
apiKey: "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
24
|
-
authDomain: "app.sendifier.com",
|
25
|
-
projectId: "sendifier-web-app",
|
26
|
-
storageBucket: "sendifier-web-app.appspot.com",
|
27
|
-
messagingSenderId: "717324879598",
|
28
|
-
appId: "1:717324879598:web:8d4f09d06c30cc435855ff"
|
29
|
-
};
|
30
|
-
firebase_auth_certification_path = `lib/certs/auth-app-cert.json`;
|
31
|
-
internal_http_request_header_key = 'x-internal-request';
|
32
|
-
internal_http_request_header_value = 'BHQGYqbN(Iu8MjgspaJzHRVSyahvbXuLPT%rI^)FDJ(At@k3vKm3E!Qp%EcJqGDt'
|
33
|
-
http_request_header_requestidentifier_key = 'p-request-identifier';
|
34
|
-
redirect_all_requests_to_local = true;
|
35
|
-
local_api_tunnel_url = "https://humble-macaw-separately.ngrok-free.app";
|
36
|
-
local_ui_tunnel_url = "";
|
37
|
-
load_scheduled_tasks = false;
|
38
|
-
backup_databases_folder_path = "";
|
39
|
-
external_http_request_timeout=5000;
|
40
|
-
|
41
|
-
// Authentication Configuration
|
42
|
-
auth: AuthConfig = {
|
43
|
-
enabled_providers: [AuthProvider.INTERNAL, AuthProvider.FIREBASE, AuthProvider.SMS_OTP, AuthProvider.EMAIL_OTP],
|
44
|
-
default_provider: AuthProvider.INTERNAL,
|
45
|
-
|
46
|
-
jwt: {
|
47
|
-
secret: process.env.JWT_SECRET || 'your-super-secret-jwt-key-change-in-production',
|
48
|
-
expires_in: '24h',
|
49
|
-
refresh_token_expires_in: '7d',
|
50
|
-
issuer: 'diagramers-api',
|
51
|
-
audience: 'diagramers-users'
|
52
|
-
},
|
53
|
-
|
54
|
-
internal: {
|
55
|
-
password_min_length: 8,
|
56
|
-
password_require_uppercase: true,
|
57
|
-
password_require_lowercase: true,
|
58
|
-
password_require_numbers: true,
|
59
|
-
password_require_special_chars: true,
|
60
|
-
max_login_attempts: 5,
|
61
|
-
lockout_duration_minutes: 15,
|
62
|
-
require_email_verification: true,
|
63
|
-
require_phone_verification: false
|
64
|
-
},
|
65
|
-
|
66
|
-
firebase: {
|
67
|
-
enabled: true,
|
68
|
-
project_id: process.env.FIREBASE_PROJECT_ID || "sendifier-web-app",
|
69
|
-
private_key_path: process.env.FIREBASE_PRIVATE_KEY_PATH || "lib/certs/auth-app-cert.json",
|
70
|
-
client_email: process.env.FIREBASE_CLIENT_EMAIL || "",
|
71
|
-
api_key: process.env.FIREBASE_API_KEY || "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
72
|
-
auth_domain: process.env.FIREBASE_AUTH_DOMAIN || "app.sendifier.com",
|
73
|
-
storage_bucket: process.env.FIREBASE_STORAGE_BUCKET || "sendifier-web-app.appspot.com",
|
74
|
-
messaging_sender_id: process.env.FIREBASE_MESSAGING_SENDER_ID || "717324879598",
|
75
|
-
app_id: process.env.FIREBASE_APP_ID || "1:717324879598:web:8d4f09d06c30cc435855ff"
|
76
|
-
},
|
77
|
-
|
78
|
-
oauth: {
|
79
|
-
enabled_providers: [OAuthProvider.GOOGLE, OAuthProvider.FACEBOOK, OAuthProvider.GITHUB],
|
80
|
-
providers: {
|
81
|
-
[OAuthProvider.GOOGLE]: {
|
82
|
-
client_id: process.env.GOOGLE_CLIENT_ID || "",
|
83
|
-
client_secret: process.env.GOOGLE_CLIENT_SECRET || "",
|
84
|
-
redirect_uri: process.env.GOOGLE_REDIRECT_URI || "https://api.sendifier.com/auth/google/callback",
|
85
|
-
scope: ['email', 'profile'],
|
86
|
-
enabled: true
|
87
|
-
},
|
88
|
-
[OAuthProvider.FACEBOOK]: {
|
89
|
-
client_id: process.env.FACEBOOK_CLIENT_ID || "",
|
90
|
-
client_secret: process.env.FACEBOOK_CLIENT_SECRET || "",
|
91
|
-
redirect_uri: process.env.FACEBOOK_REDIRECT_URI || "https://api.sendifier.com/auth/facebook/callback",
|
92
|
-
scope: ['email', 'public_profile'],
|
93
|
-
enabled: true
|
94
|
-
},
|
95
|
-
[OAuthProvider.GITHUB]: {
|
96
|
-
client_id: process.env.GITHUB_CLIENT_ID || "",
|
97
|
-
client_secret: process.env.GITHUB_CLIENT_SECRET || "",
|
98
|
-
redirect_uri: process.env.GITHUB_REDIRECT_URI || "https://api.sendifier.com/auth/github/callback",
|
99
|
-
scope: ['user:email'],
|
100
|
-
enabled: true
|
101
|
-
}
|
102
|
-
},
|
103
|
-
callback_url: "https://api.sendifier.com/auth/callback",
|
104
|
-
state_secret: process.env.OAUTH_STATE_SECRET || "your-oauth-state-secret"
|
105
|
-
},
|
106
|
-
|
107
|
-
sms_otp: {
|
108
|
-
enabled: true,
|
109
|
-
provider: 'twilio',
|
110
|
-
twilio: {
|
111
|
-
account_sid: process.env.TWILIO_ACCOUNT_SID || 'AC55b03a222fa486300e5791d8f34cfacd',
|
112
|
-
auth_token: process.env.TWILIO_AUTH_TOKEN || 'c3cc0022815391e027b7bf4bac47b46c',
|
113
|
-
from_number: process.env.TWILIO_FROM_NUMBER || '+1234567890'
|
114
|
-
},
|
115
|
-
otp_length: 6,
|
116
|
-
otp_expiry_minutes: 10,
|
117
|
-
max_attempts: 3
|
118
|
-
},
|
119
|
-
|
120
|
-
email_otp: {
|
121
|
-
enabled: true,
|
122
|
-
smtp: {
|
123
|
-
host: process.env.SMTP_HOST || 'smtp.gmail.com',
|
124
|
-
port: parseInt(process.env.SMTP_PORT || '587'),
|
125
|
-
secure: false,
|
126
|
-
user: process.env.SMTP_USER || 'your-email@gmail.com',
|
127
|
-
pass: process.env.SMTP_PASS || 'your-app-password'
|
128
|
-
},
|
129
|
-
otp_length: 6,
|
130
|
-
otp_expiry_minutes: 15,
|
131
|
-
max_attempts: 3,
|
132
|
-
from_email: process.env.FROM_EMAIL || 'noreply@diagramers.com',
|
133
|
-
from_name: process.env.FROM_NAME || 'Diagramers'
|
134
|
-
},
|
135
|
-
|
136
|
-
session: {
|
137
|
-
max_sessions_per_user: 5,
|
138
|
-
session_timeout_minutes: 1440, // 24 hours
|
139
|
-
remember_me_days: 30,
|
140
|
-
concurrent_login_allowed: true
|
141
|
-
}
|
142
|
-
};
|
143
|
-
|
144
|
-
};
|
145
|
-
export default new Production();
|
@@ -1,144 +0,0 @@
|
|
1
|
-
import { WhatsappProviders, AuthProvider, OAuthProvider } from "../helpers/enums";
|
2
|
-
import { IConfigProps, WhatsappProvidersConfig, AuthConfig } from "./config-interface";
|
3
|
-
|
4
|
-
class Staging implements IConfigProps {
|
5
|
-
isDev = false;
|
6
|
-
isProd = true;
|
7
|
-
host_name: string = 'https://api-staging.sendifier.com';
|
8
|
-
port: string = process.env.PORT || '8000';
|
9
|
-
development_environment_url: 'https://humble-macaw-separately.ngrok-free.app'
|
10
|
-
database_connectionstring: string = "mongodb://system_user:ghp_OJWuVhmI423rew23YJMNp7gXxAlBL00UEpYa@184.72.123.229:27017/sendifier-staging";
|
11
|
-
base_site_url: string = "https://app.sendifier.com";
|
12
|
-
register_complete_page_url: string = "register_complete";
|
13
|
-
whatsapp_default_provider: WhatsappProviders = WhatsappProviders.twilio;
|
14
|
-
whatsapp_providers_configurations = [{
|
15
|
-
key: WhatsappProviders.twilio,
|
16
|
-
value: {
|
17
|
-
provider_type: WhatsappProviders.twilio,
|
18
|
-
account_id: 'AC55b03a222fa486300e5791d8f34cfacd',
|
19
|
-
token: 'c3cc0022815391e027b7bf4bac47b46c'
|
20
|
-
}
|
21
|
-
}];
|
22
|
-
firebase_application_config = {
|
23
|
-
apiKey: "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
24
|
-
authDomain: "app.sendifier.com",
|
25
|
-
projectId: "sendifier-web-app",
|
26
|
-
storageBucket: "sendifier-web-app.appspot.com",
|
27
|
-
messagingSenderId: "717324879598",
|
28
|
-
appId: "1:717324879598:web:8d4f09d06c30cc435855ff"
|
29
|
-
};
|
30
|
-
firebase_auth_certification_path = `lib/certs/auth-app-cert.json`;
|
31
|
-
internal_http_request_header_key = 'x-internal-request';
|
32
|
-
internal_http_request_header_value = 'BHQGYqbN(Iu8MjgspaJzHRVSyahvbXuLPT%rI^)FDJ(At@k3vKm3E!Qp%EcJqGDt'
|
33
|
-
http_request_header_requestidentifier_key = 'p-request-identifier';
|
34
|
-
redirect_all_requests_to_local = false;
|
35
|
-
local_api_tunnel_url = "https://humble-macaw-separately.ngrok-free.app";
|
36
|
-
local_ui_tunnel_url = "";
|
37
|
-
load_scheduled_tasks = false;
|
38
|
-
backup_databases_folder_path = "";
|
39
|
-
external_http_request_timeout = 10000;
|
40
|
-
|
41
|
-
// Authentication Configuration
|
42
|
-
auth: AuthConfig = {
|
43
|
-
enabled_providers: [AuthProvider.INTERNAL, AuthProvider.FIREBASE, AuthProvider.SMS_OTP, AuthProvider.EMAIL_OTP],
|
44
|
-
default_provider: AuthProvider.INTERNAL,
|
45
|
-
|
46
|
-
jwt: {
|
47
|
-
secret: process.env.JWT_SECRET || 'your-super-secret-jwt-key-change-in-production',
|
48
|
-
expires_in: '24h',
|
49
|
-
refresh_token_expires_in: '7d',
|
50
|
-
issuer: 'diagramers-api',
|
51
|
-
audience: 'diagramers-users'
|
52
|
-
},
|
53
|
-
|
54
|
-
internal: {
|
55
|
-
password_min_length: 8,
|
56
|
-
password_require_uppercase: true,
|
57
|
-
password_require_lowercase: true,
|
58
|
-
password_require_numbers: true,
|
59
|
-
password_require_special_chars: true,
|
60
|
-
max_login_attempts: 5,
|
61
|
-
lockout_duration_minutes: 15,
|
62
|
-
require_email_verification: true,
|
63
|
-
require_phone_verification: false
|
64
|
-
},
|
65
|
-
|
66
|
-
firebase: {
|
67
|
-
enabled: true,
|
68
|
-
project_id: process.env.FIREBASE_PROJECT_ID || "sendifier-web-app",
|
69
|
-
private_key_path: process.env.FIREBASE_PRIVATE_KEY_PATH || "lib/certs/auth-app-cert.json",
|
70
|
-
client_email: process.env.FIREBASE_CLIENT_EMAIL || "",
|
71
|
-
api_key: process.env.FIREBASE_API_KEY || "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
72
|
-
auth_domain: process.env.FIREBASE_AUTH_DOMAIN || "app.sendifier.com",
|
73
|
-
storage_bucket: process.env.FIREBASE_STORAGE_BUCKET || "sendifier-web-app.appspot.com",
|
74
|
-
messaging_sender_id: process.env.FIREBASE_MESSAGING_SENDER_ID || "717324879598",
|
75
|
-
app_id: process.env.FIREBASE_APP_ID || "1:717324879598:web:8d4f09d06c30cc435855ff"
|
76
|
-
},
|
77
|
-
|
78
|
-
oauth: {
|
79
|
-
enabled_providers: [OAuthProvider.GOOGLE, OAuthProvider.FACEBOOK, OAuthProvider.GITHUB],
|
80
|
-
providers: {
|
81
|
-
[OAuthProvider.GOOGLE]: {
|
82
|
-
client_id: process.env.GOOGLE_CLIENT_ID || "",
|
83
|
-
client_secret: process.env.GOOGLE_CLIENT_SECRET || "",
|
84
|
-
redirect_uri: process.env.GOOGLE_REDIRECT_URI || "https://api-staging.sendifier.com/auth/google/callback",
|
85
|
-
scope: ['email', 'profile'],
|
86
|
-
enabled: true
|
87
|
-
},
|
88
|
-
[OAuthProvider.FACEBOOK]: {
|
89
|
-
client_id: process.env.FACEBOOK_CLIENT_ID || "",
|
90
|
-
client_secret: process.env.FACEBOOK_CLIENT_SECRET || "",
|
91
|
-
redirect_uri: process.env.FACEBOOK_REDIRECT_URI || "https://api-staging.sendifier.com/auth/facebook/callback",
|
92
|
-
scope: ['email', 'public_profile'],
|
93
|
-
enabled: true
|
94
|
-
},
|
95
|
-
[OAuthProvider.GITHUB]: {
|
96
|
-
client_id: process.env.GITHUB_CLIENT_ID || "",
|
97
|
-
client_secret: process.env.GITHUB_CLIENT_SECRET || "",
|
98
|
-
redirect_uri: process.env.GITHUB_REDIRECT_URI || "https://api-staging.sendifier.com/auth/github/callback",
|
99
|
-
scope: ['user:email'],
|
100
|
-
enabled: true
|
101
|
-
}
|
102
|
-
},
|
103
|
-
callback_url: "https://api-staging.sendifier.com/auth/callback",
|
104
|
-
state_secret: process.env.OAUTH_STATE_SECRET || "your-oauth-state-secret"
|
105
|
-
},
|
106
|
-
|
107
|
-
sms_otp: {
|
108
|
-
enabled: true,
|
109
|
-
provider: 'twilio',
|
110
|
-
twilio: {
|
111
|
-
account_sid: process.env.TWILIO_ACCOUNT_SID || 'AC55b03a222fa486300e5791d8f34cfacd',
|
112
|
-
auth_token: process.env.TWILIO_AUTH_TOKEN || 'c3cc0022815391e027b7bf4bac47b46c',
|
113
|
-
from_number: process.env.TWILIO_FROM_NUMBER || '+1234567890'
|
114
|
-
},
|
115
|
-
otp_length: 6,
|
116
|
-
otp_expiry_minutes: 10,
|
117
|
-
max_attempts: 3
|
118
|
-
},
|
119
|
-
|
120
|
-
email_otp: {
|
121
|
-
enabled: true,
|
122
|
-
smtp: {
|
123
|
-
host: process.env.SMTP_HOST || 'smtp.gmail.com',
|
124
|
-
port: parseInt(process.env.SMTP_PORT || '587'),
|
125
|
-
secure: false,
|
126
|
-
user: process.env.SMTP_USER || 'your-email@gmail.com',
|
127
|
-
pass: process.env.SMTP_PASS || 'your-app-password'
|
128
|
-
},
|
129
|
-
otp_length: 6,
|
130
|
-
otp_expiry_minutes: 15,
|
131
|
-
max_attempts: 3,
|
132
|
-
from_email: process.env.FROM_EMAIL || 'noreply@diagramers.com',
|
133
|
-
from_name: process.env.FROM_NAME || 'Diagramers'
|
134
|
-
},
|
135
|
-
|
136
|
-
session: {
|
137
|
-
max_sessions_per_user: 5,
|
138
|
-
session_timeout_minutes: 1440, // 24 hours
|
139
|
-
remember_me_days: 30,
|
140
|
-
concurrent_login_allowed: true
|
141
|
-
}
|
142
|
-
};
|
143
|
-
};
|
144
|
-
export default new Staging();
|
@@ -1,144 +0,0 @@
|
|
1
|
-
import { WhatsappProviders, AuthProvider, OAuthProvider } from "../helpers/enums";
|
2
|
-
import { IConfigProps, WhatsappProvidersConfig, AuthConfig } from "./config-interface";
|
3
|
-
|
4
|
-
class Staging implements IConfigProps {
|
5
|
-
isDev = false;
|
6
|
-
isProd = true;
|
7
|
-
host_name: string = 'https://api-staging.sendifier.com';
|
8
|
-
port: string = process.env.PORT || '8000';
|
9
|
-
development_environment_url: 'https://humble-macaw-separately.ngrok-free.app'
|
10
|
-
database_connectionstring: string = "mongodb://system_user:ghp_OJWuVhmI423rew23YJMNp7gXxAlBL00UEpYa@184.72.123.229:27017/sendifier-staging";
|
11
|
-
base_site_url: string = "https://app.sendifier.com";
|
12
|
-
register_complete_page_url: string = "register_complete";
|
13
|
-
whatsapp_default_provider: WhatsappProviders = WhatsappProviders.twilio;
|
14
|
-
whatsapp_providers_configurations = [{
|
15
|
-
key: WhatsappProviders.twilio,
|
16
|
-
value: {
|
17
|
-
provider_type: WhatsappProviders.twilio,
|
18
|
-
account_id: 'AC55b03a222fa486300e5791d8f34cfacd',
|
19
|
-
token: 'c3cc0022815391e027b7bf4bac47b46c'
|
20
|
-
}
|
21
|
-
}];
|
22
|
-
firebase_application_config = {
|
23
|
-
apiKey: "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
24
|
-
authDomain: "app.sendifier.com",
|
25
|
-
projectId: "sendifier-web-app",
|
26
|
-
storageBucket: "sendifier-web-app.appspot.com",
|
27
|
-
messagingSenderId: "717324879598",
|
28
|
-
appId: "1:717324879598:web:8d4f09d06c30cc435855ff"
|
29
|
-
};
|
30
|
-
firebase_auth_certification_path = `lib/certs/auth-app-cert.json`;
|
31
|
-
internal_http_request_header_key = 'x-internal-request';
|
32
|
-
internal_http_request_header_value = 'BHQGYqbN(Iu8MjgspaJzHRVSyahvbXuLPT%rI^)FDJ(At@k3vKm3E!Qp%EcJqGDt'
|
33
|
-
http_request_header_requestidentifier_key = 'p-request-identifier';
|
34
|
-
redirect_all_requests_to_local = false;
|
35
|
-
local_api_tunnel_url = "https://humble-macaw-separately.ngrok-free.app";
|
36
|
-
local_ui_tunnel_url = "";
|
37
|
-
load_scheduled_tasks = false;
|
38
|
-
backup_databases_folder_path = "";
|
39
|
-
external_http_request_timeout = 10000;
|
40
|
-
|
41
|
-
// Authentication Configuration
|
42
|
-
auth: AuthConfig = {
|
43
|
-
enabled_providers: [AuthProvider.INTERNAL, AuthProvider.FIREBASE, AuthProvider.SMS_OTP, AuthProvider.EMAIL_OTP],
|
44
|
-
default_provider: AuthProvider.INTERNAL,
|
45
|
-
|
46
|
-
jwt: {
|
47
|
-
secret: process.env.JWT_SECRET || 'your-super-secret-jwt-key-change-in-production',
|
48
|
-
expires_in: '24h',
|
49
|
-
refresh_token_expires_in: '7d',
|
50
|
-
issuer: 'diagramers-api',
|
51
|
-
audience: 'diagramers-users'
|
52
|
-
},
|
53
|
-
|
54
|
-
internal: {
|
55
|
-
password_min_length: 8,
|
56
|
-
password_require_uppercase: true,
|
57
|
-
password_require_lowercase: true,
|
58
|
-
password_require_numbers: true,
|
59
|
-
password_require_special_chars: true,
|
60
|
-
max_login_attempts: 5,
|
61
|
-
lockout_duration_minutes: 15,
|
62
|
-
require_email_verification: true,
|
63
|
-
require_phone_verification: false
|
64
|
-
},
|
65
|
-
|
66
|
-
firebase: {
|
67
|
-
enabled: true,
|
68
|
-
project_id: process.env.FIREBASE_PROJECT_ID || "sendifier-web-app",
|
69
|
-
private_key_path: process.env.FIREBASE_PRIVATE_KEY_PATH || "lib/certs/auth-app-cert.json",
|
70
|
-
client_email: process.env.FIREBASE_CLIENT_EMAIL || "",
|
71
|
-
api_key: process.env.FIREBASE_API_KEY || "AIzaSyCyRHzm2f_CooMRbYpRVV0MpptBu-HdEs4",
|
72
|
-
auth_domain: process.env.FIREBASE_AUTH_DOMAIN || "app.sendifier.com",
|
73
|
-
storage_bucket: process.env.FIREBASE_STORAGE_BUCKET || "sendifier-web-app.appspot.com",
|
74
|
-
messaging_sender_id: process.env.FIREBASE_MESSAGING_SENDER_ID || "717324879598",
|
75
|
-
app_id: process.env.FIREBASE_APP_ID || "1:717324879598:web:8d4f09d06c30cc435855ff"
|
76
|
-
},
|
77
|
-
|
78
|
-
oauth: {
|
79
|
-
enabled_providers: [OAuthProvider.GOOGLE, OAuthProvider.FACEBOOK, OAuthProvider.GITHUB],
|
80
|
-
providers: {
|
81
|
-
[OAuthProvider.GOOGLE]: {
|
82
|
-
client_id: process.env.GOOGLE_CLIENT_ID || "",
|
83
|
-
client_secret: process.env.GOOGLE_CLIENT_SECRET || "",
|
84
|
-
redirect_uri: process.env.GOOGLE_REDIRECT_URI || "https://api-uat.sendifier.com/auth/google/callback",
|
85
|
-
scope: ['email', 'profile'],
|
86
|
-
enabled: true
|
87
|
-
},
|
88
|
-
[OAuthProvider.FACEBOOK]: {
|
89
|
-
client_id: process.env.FACEBOOK_CLIENT_ID || "",
|
90
|
-
client_secret: process.env.FACEBOOK_CLIENT_SECRET || "",
|
91
|
-
redirect_uri: process.env.FACEBOOK_REDIRECT_URI || "https://api-uat.sendifier.com/auth/facebook/callback",
|
92
|
-
scope: ['email', 'public_profile'],
|
93
|
-
enabled: true
|
94
|
-
},
|
95
|
-
[OAuthProvider.GITHUB]: {
|
96
|
-
client_id: process.env.GITHUB_CLIENT_ID || "",
|
97
|
-
client_secret: process.env.GITHUB_CLIENT_SECRET || "",
|
98
|
-
redirect_uri: process.env.GITHUB_REDIRECT_URI || "https://api-uat.sendifier.com/auth/github/callback",
|
99
|
-
scope: ['user:email'],
|
100
|
-
enabled: true
|
101
|
-
}
|
102
|
-
},
|
103
|
-
callback_url: "https://api-uat.sendifier.com/auth/callback",
|
104
|
-
state_secret: process.env.OAUTH_STATE_SECRET || "your-oauth-state-secret"
|
105
|
-
},
|
106
|
-
|
107
|
-
sms_otp: {
|
108
|
-
enabled: true,
|
109
|
-
provider: 'twilio',
|
110
|
-
twilio: {
|
111
|
-
account_sid: process.env.TWILIO_ACCOUNT_SID || 'AC55b03a222fa486300e5791d8f34cfacd',
|
112
|
-
auth_token: process.env.TWILIO_AUTH_TOKEN || 'c3cc0022815391e027b7bf4bac47b46c',
|
113
|
-
from_number: process.env.TWILIO_FROM_NUMBER || '+1234567890'
|
114
|
-
},
|
115
|
-
otp_length: 6,
|
116
|
-
otp_expiry_minutes: 10,
|
117
|
-
max_attempts: 3
|
118
|
-
},
|
119
|
-
|
120
|
-
email_otp: {
|
121
|
-
enabled: true,
|
122
|
-
smtp: {
|
123
|
-
host: process.env.SMTP_HOST || 'smtp.gmail.com',
|
124
|
-
port: parseInt(process.env.SMTP_PORT || '587'),
|
125
|
-
secure: false,
|
126
|
-
user: process.env.SMTP_USER || 'your-email@gmail.com',
|
127
|
-
pass: process.env.SMTP_PASS || 'your-app-password'
|
128
|
-
},
|
129
|
-
otp_length: 6,
|
130
|
-
otp_expiry_minutes: 15,
|
131
|
-
max_attempts: 3,
|
132
|
-
from_email: process.env.FROM_EMAIL || 'noreply@diagramers.com',
|
133
|
-
from_name: process.env.FROM_NAME || 'Diagramers'
|
134
|
-
},
|
135
|
-
|
136
|
-
session: {
|
137
|
-
max_sessions_per_user: 5,
|
138
|
-
session_timeout_minutes: 1440, // 24 hours
|
139
|
-
remember_me_days: 30,
|
140
|
-
concurrent_login_allowed: true
|
141
|
-
}
|
142
|
-
};
|
143
|
-
};
|
144
|
-
export default new Staging();
|
@@ -1,162 +0,0 @@
|
|
1
|
-
import { AuditMessageType, ResponseCode } from "../helpers/enums";
|
2
|
-
import handleResponse from "../helpers/handle-response";
|
3
|
-
import { Result } from "../helpers/result";
|
4
|
-
import { AccountService } from "../services/account-service";
|
5
|
-
|
6
|
-
export default class AccountController {
|
7
|
-
|
8
|
-
async verifyToken(req, res) {
|
9
|
-
const result = new Result(null, ResponseCode.Incompelete, [], [], req.body.requestIdentifier);
|
10
|
-
const accountService = new AccountService(result);
|
11
|
-
const serviceResult = await accountService.VerifyToken(req.body.idToken);
|
12
|
-
return handleResponse(req, res, serviceResult);
|
13
|
-
}
|
14
|
-
|
15
|
-
async activateEmail(req, res) {
|
16
|
-
const result = new Result(null, ResponseCode.Incompelete, [], [], req.body.requestIdentifier);
|
17
|
-
try {
|
18
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'activateEmail', `Started`);
|
19
|
-
const accountService = new AccountService(result);
|
20
|
-
const serviceResult = await accountService.confirmEmail(req.body);
|
21
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'activateEmail', `Finished`);
|
22
|
-
return handleResponse(req, res, serviceResult);
|
23
|
-
} catch (ex) {
|
24
|
-
result.addException(req.baseUrl, 'activateEmail', ex);
|
25
|
-
return handleResponse(req, res, result);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
async register(req, res) {
|
30
|
-
const result = res.locals.result;
|
31
|
-
try {
|
32
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'register', `Started`);
|
33
|
-
const accountService = new AccountService(result);
|
34
|
-
const serviceResult = await accountService.register(req.body);
|
35
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'register', `Finished`);
|
36
|
-
return handleResponse(req, res, serviceResult);
|
37
|
-
} catch (ex) {
|
38
|
-
result.addException(req.baseUrl, 'register', ex);
|
39
|
-
return handleResponse(req, res, result);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
async login(req, res) {
|
44
|
-
const result = res.locals.result;
|
45
|
-
try {
|
46
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'login', `Started`);
|
47
|
-
const accountService = new AccountService(result);
|
48
|
-
const serviceResult = await accountService.login(req.body);
|
49
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'login', `Finished`);
|
50
|
-
return handleResponse(req, res, serviceResult);
|
51
|
-
} catch (ex) {
|
52
|
-
result.addException(req.baseUrl, 'login', ex);
|
53
|
-
return handleResponse(req, res, result);
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
async verifySignupCode(req, res) {
|
58
|
-
const result = res.locals.result;
|
59
|
-
try {
|
60
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'verifySignupCode', `Started`);
|
61
|
-
const accountService = new AccountService(result);
|
62
|
-
const serviceResult = await accountService.VerifyMobileVerificationCode(req.body);
|
63
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'verifySignupCode', `Finished`);
|
64
|
-
return handleResponse(req, res, serviceResult);
|
65
|
-
} catch (ex) {
|
66
|
-
result.addException(req.baseUrl, 'verifySignupCode', ex);
|
67
|
-
return handleResponse(req, res, result);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
async completeSignup(req, res) {
|
72
|
-
const result = res.locals.result;
|
73
|
-
try {
|
74
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'completeSignup', `Started`);
|
75
|
-
const accountService = new AccountService(result);
|
76
|
-
const serviceResult = await accountService.completeSignup(req.body);
|
77
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'completeSignup', `Finished`);
|
78
|
-
return handleResponse(req, res, serviceResult);
|
79
|
-
} catch (ex) {
|
80
|
-
result.addException(req.baseUrl, 'completeSignup', ex);
|
81
|
-
return handleResponse(req, res, result);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
async sendSignUpEmail(req, res) {
|
86
|
-
const result = res.locals.result;
|
87
|
-
const accountService = new AccountService(result);
|
88
|
-
// Implement sendSignupEmail if needed
|
89
|
-
return handleResponse(req, res, new Result(true, ResponseCode.Ok, [], []));
|
90
|
-
}
|
91
|
-
|
92
|
-
async checkEmailIsExistForBusiness(req, res) {
|
93
|
-
const result = res.locals.result;
|
94
|
-
try {
|
95
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'checkEmailIsExistForBusiness', `Started`);
|
96
|
-
const accountService = new AccountService(result);
|
97
|
-
const serviceResult = await accountService.checkEmailIsExistForBusiness(req.body);
|
98
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'checkEmailIsExistForBusiness', `Finished`);
|
99
|
-
return handleResponse(req, res, serviceResult);
|
100
|
-
} catch (ex) {
|
101
|
-
result.addException(req.baseUrl, 'checkEmailIsExistForBusiness', ex);
|
102
|
-
return handleResponse(req, res, result);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
async checkPhoneIsExistForBusiness(req, res) {
|
107
|
-
const result = res.locals.result;
|
108
|
-
try {
|
109
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'checkPhoneIsExistForBusiness', `Started`);
|
110
|
-
const accountService = new AccountService(result);
|
111
|
-
const serviceResult = await accountService.checkPhoneIsExistForBusiness(req.body);
|
112
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'checkPhoneIsExistForBusiness', `Finished`);
|
113
|
-
return handleResponse(req, res, serviceResult);
|
114
|
-
} catch (ex) {
|
115
|
-
result.addException(req.baseUrl, 'checkPhoneIsExistForBusiness', ex);
|
116
|
-
return handleResponse(req, res, result);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
async resetUserPassword(req, res) {
|
121
|
-
const result = res.locals.result;
|
122
|
-
try {
|
123
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'resetUserPassword', `Started`);
|
124
|
-
const accountService = new AccountService(result);
|
125
|
-
const serviceResult = await accountService.resetUserPassword(req.body);
|
126
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'resetUserPassword', `Finished`);
|
127
|
-
return handleResponse(req, res, serviceResult);
|
128
|
-
} catch (ex) {
|
129
|
-
result.addException(req.baseUrl, 'resetUserPassword', ex);
|
130
|
-
return handleResponse(req, res, result);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
async requestResetUserPassword(req, res) {
|
135
|
-
const result = res.locals.result;
|
136
|
-
try {
|
137
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'requestResetUserPassword', `Started`);
|
138
|
-
const accountService = new AccountService(result);
|
139
|
-
const serviceResult = await accountService.requestResettUserPassword(req.body);
|
140
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'requestResetUserPassword', `Finished`);
|
141
|
-
return handleResponse(req, res, serviceResult);
|
142
|
-
} catch (ex) {
|
143
|
-
result.addException(req.baseUrl, 'requestResetUserPassword', ex);
|
144
|
-
return handleResponse(req, res, result);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
// ✅ NEW: Seed user method for seeding admin user
|
149
|
-
async seedUser(req, res) {
|
150
|
-
const result = new Result(null, ResponseCode.Incompelete, [], [], req.body?.requestIdentifier);
|
151
|
-
try {
|
152
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'seedUser', `Started`);
|
153
|
-
const accountService = new AccountService(result);
|
154
|
-
const serviceResult = await accountService.seedUser();
|
155
|
-
result.addMessage(AuditMessageType.info, req.baseUrl, 'seedUser', `Finished`);
|
156
|
-
return handleResponse(req, res, serviceResult);
|
157
|
-
} catch (ex) {
|
158
|
-
result.addException(req.baseUrl, 'seedUser', ex);
|
159
|
-
return handleResponse(req, res, result);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import * as mongoose from 'mongoose';
|
2
|
-
import { ObjectId } from 'bson';
|
3
|
-
import { IBaseEntity } from './base-entity';
|
4
|
-
|
5
|
-
export interface IAudit extends IBaseEntity {
|
6
|
-
type: string;
|
7
|
-
auditTime: string;
|
8
|
-
className: string;
|
9
|
-
methodName: string;
|
10
|
-
message: string;
|
11
|
-
additionalInfo: JSON;
|
12
|
-
}
|