-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from King-AJr/feat/create-email-templates
feat: store hng email templates and update create email endpoint
- Loading branch information
Showing
36 changed files
with
7,256 additions
and
301 deletions.
There are no files selected for viewing
15 changes: 3 additions & 12 deletions
15
src/modules/email/email_storage.service.ts → src/helpers/fileHelpers.ts
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 |
---|---|---|
@@ -1,34 +1,25 @@ | ||
import * as fs from 'fs'; | ||
import { promisify } from 'util'; | ||
|
||
/** Check if a file exists at a given path.*/ | ||
export const checkIfFileOrDirectoryExists = (path: string): boolean => { | ||
return fs.existsSync(path); | ||
}; | ||
|
||
/** Gets file data from a given path via a promise interface.*/ | ||
export const getFile = async (path: string, encoding?: BufferEncoding): Promise<string | Buffer> => { | ||
const readFile = promisify(fs.readFile); | ||
|
||
return encoding ? readFile(path, { encoding }) : readFile(path); | ||
}; | ||
|
||
/** Writes a file at a given path via a promise interface */ | ||
export const createFile = async (path: string, fileName: string, data: string): Promise<void> => { | ||
if (!checkIfFileOrDirectoryExists(path)) { | ||
fs.mkdirSync(path); | ||
fs.mkdirSync(path, { recursive: true }); | ||
} | ||
|
||
console.log(`Creating file at ${path}/${fileName}`); | ||
|
||
const writeFile = promisify(fs.writeFile); | ||
|
||
return await writeFile(`${path}/${fileName}`, data, 'utf8'); | ||
await writeFile(`${path}/${fileName}`, data, 'utf8'); | ||
}; | ||
|
||
/**Delete file at the given path via a promise interface*/ | ||
export const deleteFile = async (path: string): Promise<void> => { | ||
const unlink = promisify(fs.unlink); | ||
|
||
return await unlink(path); | ||
await unlink(path); | ||
}; |
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
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
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
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
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
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
218 changes: 218 additions & 0 deletions
218
src/modules/email/hng-templates/Account-Deactivation.hbs
Large diffs are not rendered by default.
Oops, something went wrong.
223 changes: 223 additions & 0 deletions
223
src/modules/email/hng-templates/Account-Inactivity-Deactivation.hbs
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.