-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.ts
151 lines (130 loc) · 4.12 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* [SERVER SIDE] MAIN CONFIG FILE
*/
import * as path from 'path';
import { diskStorage } from 'multer';
import { MulterModuleOptions } from '@nestjs/platform-express/multer';
const isProduction: boolean = process.env.NODE_ENV === 'production';
// Render.com provides a DATABASE_URL environment variable
// DATABASE_URL="postgres://root:root@postgresql:5432/root"
const DATABASE_URL: string = isProduction
? process.env.DATABASE_URL || ''
: 'postgres://root:root@localhost:5432/root';
export const firebaseConfig = {
storageBucket:
process.env.storageBucket || 'gs://into-the-shelter.appspot.com',
type: 'service_account',
project_id: 'into-the-shelter',
private_key_id: process.env.private_key_id,
private_key: process.env.private_key,
client_email:
client_id: '100916296756280661809',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url:
'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-buiok%40into-the-shelter.iam.gserviceaccount.com',
universe_domain: 'googleapis.com',
};
const CLIENT_URL: string = isProduction
? process.env.CLIENT_URL || ''
: 'http://localhost:3000';
const ML_URL: string = isProduction
? process.env.ML_URL || ''
: 'http://localhost:8008'; // or replace localhost with docker container name (http://shelter-ml:8008)
// GENERAL CONFIGS
export const multerConfig: MulterModuleOptions = {
storage: diskStorage({
destination: (req, file, cb) => {
cb(null, 'data/images');
},
filename: (req, file, cb) => {
const filename: string =
path.parse(file.originalname).name.replace(/\s/g, '') +
'-' +
Date.now();
cb(null, `${filename}${path.extname(file.originalname)}`);
},
}),
};
export const LOBBY_MAX_LIFETIME = 60 * 60 * 1000; // 1h
// MODULE CONFINGS
export default () => ({
isProduction,
DATABASE_URL,
CLIENT_URL,
ML_URL,
// PORTS
CLIENT_PORT: process.env.CLIENT_PORT || 3000,
GATEWAY_PORT: process.env.GATEWAY_PORT || 8000,
ACCOUNTS_PORT: process.env.ACCOUNTS_PORT || 8001,
ML_PORT: process.env.ML_PORT || 8008,
// SESSIONS
SESSION_SECRET: process.env.SESSION_SECRET || 'MyS1cr3t',
maxAge: process.env.maxAge || 60000 * 60 * 24, // 1d
// Google OAuth2
CLIENT_ID: process.env.CLIENT_ID,
CLIENT_SECRET: process.env.CLIENT_SECRET,
CALLBACK_URL: process.env.CALLBACK_URL,
});
// AI CONFIGURATIONS
// https://api.together.xyz/
const AI_URL_1 = 'https://api.together.xyz/v1';
const AI_KEY_1 = process.env.AI_KEY_1;
const AI_MODELS_1 = [
'QWEN/QWEN1.5-72B-CHAT',
'mistralai/Mixtral-8x7B-Instruct-v0.1', // Mistral AI
'GARAGE-BAIND/PLATYPUS2-70B-INSTRUCT',
'NOUSRESEARCH/NOUS-HERMES-2-MIXTRAL-8X7B-SFT',
];
// https://api.groq.com/
const AI_URL_2 = 'https://api.groq.com/openai/v1';
const AI_KEY_2 = process.env.AI_KEY_2;
const AI_MODELS_2 = [
'gemma-7b-it', // Google
'mixtral-8x7b-32768', // Mistral AI
'llama3-70b-8192', // Meta
'llama3-8b-8192', // Meta
];
export const AI_CONFIGS = {
TOGETHER: {
URL: AI_URL_1,
KEY: AI_KEY_1,
MODELS: AI_MODELS_1,
},
GROQ: {
URL: AI_URL_2,
KEY: AI_KEY_2,
MODELS: AI_MODELS_2,
},
};
export const AI = AI_CONFIGS.GROQ; // current, actual ai api, used all over the app
// ---
// PAYPAL
export const PAYPAL_CLIENT_ID: string = isProduction
? process.env.PAYPAL_CLIENT_ID
: process.env.SANDBOX_PAYPAL_CLIENT_ID;
export const PAYPAL_CLIENT_SECRET: string = isProduction
? process.env.PAYPAL_CLIENT_SECRET
: process.env.SANDBOX_PAYPAL_CLIENT_SECRET;
export const sandboxUrl = 'https://api-m.sandbox.paypal.com';
// PAYMENTS
interface Product {
coins: number;
price: string;
}
export const payProducts: {
[key: string]: Product;
} = {
'1': { coins: 20, price: '1.00' },
'2': { coins: 100, price: '3.00' },
'3': { coins: 200, price: '5.00' },
'4': { coins: 440, price: '10.00' },
};
export const buyProducts: {
[key: string]: { price: number };
} = {
'101': { price: 80 },
'102': { price: 60 },
};