Skip to content

Commit

Permalink
Merge pull request #48 from Lavavarshney/main
Browse files Browse the repository at this point in the history
FEAT: Added nodemailer snippet, updated README.md file,  updated snippet dependencies
  • Loading branch information
PranavBarthwal authored Oct 26, 2024
2 parents 5eb5fdb + e275f7d commit 9179bb9
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,34 @@ This command will create a new file `multer-file-upload.js` in the current worki

```

7. 6. **`nodemailer`**:
Sets up email functionality in Node.js projects

**Code Snippet**:
```js
const nodemailer = require('nodemailer');
require('dotenv').config();
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.EMAIL_PASSWORD
},
});
const mailOptions = {
from: process.env.EMAIL,
to: '[email protected]',
subject: 'Hello from Nodemailer',
text: 'This is a plain text body!',
html: '<p>This is an <b>HTML</b> body!</p>',
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Email sent: ' + info.response);
})
```
### 3. `run generate-ai-snippet <snippetName>`
With the new AI-powered code generation feature, you can generate customized code snippets. For instance, to generate a code snippet for a specific backend functionality, you can run:

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import inquirer from 'inquirer'; // Import the inquirer package
import { exec } from 'child_process'
import { generateGitignore } from './gitignoreGenerator.js';
import { dependencies } from './snippetdependencies.js';
=======



const __filename = fileURLToPath(import.meta.url);
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dotenv": "^16.4.5",
"fs-extra": "^11.2.0",
"inquirer": "^10.2.2",
"nodemailer": "^6.9.15",
"ora": "^8.1.0"
},
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion snippetdependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const dependencies = {
"mongoose-con" : ['mongoose'],
"mongoose-schema" : ['mongoose'],
"multer-file-upload" : ['multer']
"multer-file-upload" : ['multer'] ,
"nodemailer": ['nodemailer'],
};
export {dependencies};

22 changes: 22 additions & 0 deletions snippets/nodemailer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const nodemailer = require('nodemailer');
require('dotenv').config();
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.EMAIL_PASSWORD
},
});
const mailOptions = {
from: process.env.EMAIL,
to: '[email protected]',
subject: 'Hello from Nodemailer',
text: 'This is a plain text body!',
html: '<p>This is an <b>HTML</b> body!</p>',
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Email sent: ' + info.response);
})
4 changes: 3 additions & 1 deletion templates/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ REFRESH_TOKEN_EXPIRY=10d

CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name_here
CLOUDINARY_API_KEY=your_cloudinary_api_key_here
CLOUDINARY_API_SECRET=your_cloudinary_api_secret_here
CLOUDINARY_API_SECRET=your_cloudinary_api_secret_here
EMAIL=your_email_id
PASSWORD=your_email_password

0 comments on commit 9179bb9

Please sign in to comment.