-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft(Email-microservice): separate our mail service from the rest of th…
…e system - Send email from serverless using aws-lambda. - Failed email store and send after certain minutes. [Delivery #187658871]
- Loading branch information
1 parent
1e8164b
commit a33f897
Showing
4 changed files
with
155 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/sequelize/migrations/20240527133340-create-failed-email.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable('failedEmails', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
userId: { | ||
type: Sequelize.INTEGER | ||
}, | ||
email: { | ||
type: Sequelize.STRING | ||
}, | ||
subject: { | ||
type: Sequelize.STRING | ||
}, | ||
body: { | ||
type: Sequelize.TEXT | ||
}, | ||
attempts: { | ||
type: Sequelize.INTEGER | ||
}, | ||
lastAttempted: { | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.NOW, | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}); | ||
}, | ||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable('failedEmails'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { DataTypes, Model } from 'sequelize'; | ||
import sequelize from '../../config/dbConnection'; | ||
|
||
interface FailedEmailAttributes { | ||
id: number; | ||
userId: number; | ||
email: string; | ||
subject: string; | ||
body: string; | ||
attempts: number; | ||
lastAttempted: Date; | ||
} | ||
|
||
class FailedEmail extends Model<FailedEmailAttributes> implements FailedEmailAttributes { | ||
id!: number; | ||
userId!: number; | ||
email!: string; | ||
subject!: string; | ||
body!: string; | ||
attempts!: number; | ||
lastAttempted!: Date; | ||
} | ||
|
||
FailedEmail.init({ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
}, | ||
userId: { | ||
type: DataTypes.INTEGER, | ||
allowNull: false, | ||
}, | ||
email: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
subject: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
}, | ||
body: { | ||
type: DataTypes.TEXT, | ||
allowNull: false, | ||
}, | ||
attempts: { | ||
type: DataTypes.INTEGER, | ||
defaultValue: 0, | ||
}, | ||
lastAttempted: { | ||
type: DataTypes.DATE, | ||
defaultValue: DataTypes.NOW, | ||
}, | ||
}, { | ||
sequelize, | ||
modelName: 'failedEmails', | ||
}); | ||
|
||
export default FailedEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters