Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morrismagic/node
https://github.com/morrismagic/node
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/morrismagic/node
- Owner: MorrisMagic
- Created: 2024-09-23T00:20:43.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-23T00:22:10.000Z (about 2 months ago)
- Last Synced: 2024-10-06T19:08:59.337Z (about 1 month ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
mkdir nodejs-tasks
cd nodejs-tasks
npm init -ynpm install generate-password nodemailer
// hello-world.js
console.log("HELLO WORLD");// server.js
const http = require('http');const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
res.end('Hello Node!!!!
\n');
});server.listen(3000, () => {
console.log('Server running at http://localhost:3000/');
});// file-system.js
const fs = require('fs');// Write to 'welcome.txt'
fs.writeFile('welcome.txt', 'Hello Node', (err) => {
if (err) throw err;
console.log('File has been written.');// Read from 'welcome.txt'
fs.readFile('welcome.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log('Content of welcome.txt:', data);
});
});// password-generator.js
const generatePassword = require('generate-password');function createPassword() {
const password = generatePassword.generate({
length: 12,
numbers: true,
});
console.log('Generated Password: ', password);
}createPassword();
// email-sender.js
const nodemailer = require('nodemailer');// Set up the transporter
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]', // Replace with your Gmail email
pass: 'your-email-password' // Replace with your Gmail password
}
});// Email details
let mailOptions = {
from: '[email protected]', // Your email
to: '[email protected]', // Recipient email
subject: 'Hello from Node.js',
text: 'This is a test email sent from a Node.js app.'
};// Send the email
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Email sent: ' + info.response);
});