diff --git a/src/environment.ts b/src/environment.ts index 64199e3..6f2a659 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -5,7 +5,7 @@ dotenv.config(); export default { dbConnectionString: (process.env.NODE_ENV == 'production') ? `mongodb://${process.env.DB_USER}:${encodeURIComponent(process.env.DB_PASS || '')}@${process.env.DB_HOSTS}/${process.env.DB}${process.env.DB_OPTIONS}`: - 'mongodb://localhost:27017', + 'mongodb://localhost:27017/mango_alerts', db: process.env.DB || '', port: process.env.PORT || 3000, diff --git a/src/index.ts b/src/index.ts index b831848..60f6ea5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,7 +38,6 @@ router.get('/', async(ctx, next) => { }) router.post('/alerts', async(ctx, next) => { - sendLogsToDiscord('Alert called', null); try { const alert = ctx.request.body; await validateMarginAccount(client, connection, dexProgramId, alert); @@ -57,7 +56,7 @@ router.post('/alerts', async(ctx, next) => { throw new UserError('Invalid alert provider'); } alert.open = true; - alert.timestamp = new Date(); + alert.timestamp = Date.now(); ctx.db.collection('alerts').insertOne(alert); } catch (e) { let errorMessage = 'Something went wrong'; @@ -105,9 +104,8 @@ const runCron = async () => { } } }); - const expiryTime = new Date( Date.now() - (1000 * 60 * 1) ); // 15 Minutes - console.log(expiryTime); - db.collection('alerts').deleteMany({ tgChatId: { $exists: false }, timestamp: { '$lt': expiryTime } }); + const expiryTime = Date.now() - (1000 * 60 * 15); // 15 Minutes + db.collection('alerts').deleteMany({ tgChatId: { '$exists': false }, timestamp: { '$lt': expiryTime } }); } catch (e) { sendLogsToDiscord(null, e); }