-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* userfile added * test pushing * ass2 * adding put method * pushing new files * removing kerys * changed the file * changed the file * changed the file * sdsad * sdsad * sasdsaad * sasdsaad * sasdsaad * sasdsaad * sasdsaad * sasdsaad * assad * assad * assad * assad * workflow * asda * asdsa * asdsa * asdsa * asdsad * asdsad * asdsad * asdsad * asdsad * asdsad * adsad * adsad * adsad * adsad * adsad * pushing env * dotenv * asdsa * add env * Commit message for config/.env file * commiting * setup.sh * deleted file * added setup file * asds * adding postgresshitagain * asdsad * commented nologin * initchange * asdsa * adding setup.sh * adding setup.sh * adding setup.sh * adding setup.sh * saad * asddsd * removing nodemoudles * dotenv * adding new stuff * adding setup file * adding setup file * asdasdsa * asasdsadsa * asdsad * asdsad
- Loading branch information
1 parent
c9e4a44
commit 29ac0d4
Showing
8,178 changed files
with
648 additions
and
880,370 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,14 @@ jobs: | |
- name: Set up Google Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
with: | ||
service_account_key: ${{ secrets.GCP_SA_KEY }} | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
||
# - name: Check Service Account Key File | ||
# run: | | ||
# if [ ! -f "${{ github.workspace }}/secrets/project4-414017-5c44874f2950.json" ]; then | ||
# echo "Error: Service account key file not found." | ||
# exit 1 | ||
# fi | ||
|
||
- name: Check Service Account Key File | ||
run: | | ||
|
@@ -39,4 +46,4 @@ jobs: | |
run: packer init ./packer/centos-stream.pkr.hcl | ||
|
||
- name: Build AMI | ||
run: packer build ./packer/centos-stream.pkr.hcl | ||
run: packer build ./packer/centos-stream.pkr.hcl |
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 |
---|---|---|
|
@@ -37,5 +37,4 @@ jobs: | |
rm -rf node_modules | ||
npm install | ||
- run: npm test | ||
- run: npm test |
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,2 @@ | ||
{ | ||
} |
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,16 @@ | ||
[Unit] | ||
Description=Webapp | ||
ConditionPathExists=/opt/csye6225/webapp/index.js | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
User=root | ||
Group=root | ||
WorkingDirectory=/opt/csye6225/webapp | ||
ExecStart=/usr/bin/node /opt/csye6225/webapp/index.js | ||
Restart=always | ||
RestartSec=3 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,5 @@ | ||
DB_HOST = 'localhost' | ||
DB_USER = 'postgres' | ||
DB_PASS = 'root' | ||
DB_NAME = 'cloudassignmentdatabase' | ||
DB_PORT = 5432 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//email the user link | ||
//verification link should expire in 2 minutes | ||
//expired link shouldnt be used | ||
const { PubSub } = require('@google-cloud/pubsub'); | ||
const nodemailer = require('nodemailer'); | ||
const crypto = require('crypto'); | ||
|
||
const pubsub = new PubSub(); | ||
const topicName = 'verify_email'; | ||
const verificationLinks = new Map(); // Store verification links in-memory (use a database for production) | ||
|
||
const transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '[email protected]', | ||
pass: 'your-email-password' | ||
} | ||
}); | ||
|
||
exports.verifyEmail = async (event, context) => { | ||
const pubsubMessage = event.data; | ||
const user = JSON.parse(Buffer.from(pubsubMessage, 'base64').toString()); | ||
|
||
const token = crypto.randomBytes(20).toString('hex'); | ||
const verificationLink = `https://your-domain.com/verify-email?token=${token}`; | ||
|
||
verificationLinks.set(token, { | ||
email: user.email, | ||
expires: Date.now() + 2 * 60 * 1000 // 2 minutes | ||
}); | ||
|
||
const mailOptions = { | ||
from: '[email protected]', | ||
to: user.email, | ||
subject: 'Verify Your Email Address', | ||
text: `Click the link to verify your email address: ${verificationLink}` | ||
}; | ||
|
||
try { | ||
await transporter.sendMail(mailOptions); | ||
console.log(`Verification email sent to ${user.email}`); | ||
} catch (error) { | ||
console.error(`Error sending verification email: ${error}`); | ||
} | ||
}; | ||
|
||
// Function to handle verification link expiration and user verification | ||
exports.handleVerification = (req, res) => { | ||
const { token } = req.query; | ||
|
||
if (!verificationLinks.has(token)) { | ||
return res.status(400).send('Invalid or expired verification link.'); | ||
} | ||
|
||
const linkData = verificationLinks.get(token); | ||
|
||
if (Date.now() > linkData.expires) { | ||
verificationLinks.delete(token); | ||
return res.status(400).send('Verification link expired.'); | ||
} | ||
|
||
// Mark user as verified in the database (implementation depends on your setup) | ||
// For example: | ||
// User.update({ email_verified: true }, { where: { email: linkData.email } }); | ||
|
||
verificationLinks.delete(token); | ||
res.send('Email verified successfully.'); | ||
}; |
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,22 @@ | ||
const { publishMessage } = require("./trial"); | ||
const topicName = "verify_email"; | ||
|
||
const welcome = (req, res) => { | ||
return res.status(200).json({ | ||
success: true, | ||
message: "Welcome to User Profile Service:)", | ||
}); | ||
}; | ||
|
||
const createUser = async (req, res) => { | ||
let userObj = req.body; | ||
// create user profile logic goes here... | ||
let messageId = await publishMessage(topicName, userObj); | ||
|
||
return res.status(200).json({ | ||
success: true, | ||
message: `Message ${messageId} published :)`, | ||
}); | ||
}; | ||
|
||
module.exports = {welcome, createUser}; |
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,74 @@ | ||
// const { PubSub } = require('@google-cloud/pubsub'); | ||
// const pubsub = new PubSub({ projectId: 'project4-414017' }); // Use the correct project ID | ||
|
||
|
||
|
||
// async function a() { | ||
// const messageBuffer = Buffer.from(JSON.stringify({"empty": "boy"})); | ||
// await pubsub.topic(topicName).publish(messageBuffer); | ||
// } | ||
|
||
// a(); | ||
|
||
const { PubSub } = require("@google-cloud/pubsub"); | ||
const path = require("path"); | ||
const topicName = 'verify_email'; // replace with your Pub/Sub topic name | ||
|
||
const keyFilePath = path.join(__dirname, "../../../gcpkey/newkey2/project4-414017-f35db3a91268.json"); | ||
const projectId = "project4-414017"; | ||
|
||
// Create an instance of PubSub with the provided service account key | ||
const pubSubClient = new PubSub({ | ||
projectId: projectId, | ||
keyFilename: keyFilePath, | ||
}); | ||
|
||
const publishMessage = async (topicName, payload) => { | ||
const dataBuffer = Buffer.from(JSON.stringify(payload)); | ||
try { | ||
const messageId = await pubSubClient | ||
.topic(topicName) | ||
.publishMessage({ data: dataBuffer }); | ||
console.log(`Message ${messageId} published.`); | ||
return messageId; | ||
} catch (error) { | ||
console.error(`Received error while publishing: ${error.message}`); | ||
} | ||
}; | ||
|
||
const listenForPullMessages = async (subscriptionName, timeout) => { | ||
const subscription = pubSubClient.subscription(subscriptionName); | ||
let messageCount = 0; | ||
let data = []; | ||
const messageHandler = message => { | ||
const jsonData = JSON.parse(message.data); | ||
|
||
data.push({ | ||
id: message.id, | ||
attributes: message.attributes, | ||
...jsonData, | ||
}); | ||
messageCount += 1; | ||
message.ack(); | ||
}; | ||
subscription.on("message", messageHandler); | ||
|
||
setTimeout(() => { | ||
console.log("Message Pulled: \n", data); | ||
console.log(`${messageCount} message(s) received.`); | ||
subscription.removeListener("message", messageHandler); | ||
}, timeout * 100); | ||
} | ||
|
||
const listenForPushMessages = payload => { | ||
const message = Buffer.from(payload, "base64").toString("utf-8"); | ||
let parsedMessage = JSON.parse(message); | ||
console.log("Message Pushed: \n", parsedMessage); | ||
return parsedMessage; | ||
} | ||
|
||
module.exports = { | ||
publishMessage, | ||
listenForPullMessages, | ||
listenForPushMessages, | ||
}; |
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,49 @@ | ||
resource "google_compute_instance" "instance-20240221-230457" { | ||
boot_disk { | ||
auto_delete = true | ||
device_name = "instance-20240221-230457" | ||
|
||
initialize_params { | ||
image = "projects/project4-414017/global/images/image-1" | ||
size = 100 | ||
type = "pd-balanced" | ||
} | ||
|
||
mode = "READ_WRITE" | ||
} | ||
|
||
can_ip_forward = false | ||
deletion_protection = false | ||
enable_display = false | ||
|
||
labels = { | ||
goog-ec-src = "vm_add-tf" | ||
} | ||
|
||
machine_type = "e2-medium" | ||
name = "instance-20240221-230457" | ||
|
||
network_interface { | ||
access_config { | ||
network_tier = "STANDARD" | ||
} | ||
|
||
queue_count = 0 | ||
stack_type = "IPV4_ONLY" | ||
subnetwork = "projects/project4-414017/regions/us-east1/subnetworks/webappsubnet" | ||
} | ||
|
||
scheduling { | ||
automatic_restart = true | ||
on_host_maintenance = "MIGRATE" | ||
preemptible = false | ||
provisioning_model = "STANDARD" | ||
} | ||
|
||
service_account { | ||
email = "[email protected]" | ||
scopes = ["https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring.write", "https://www.googleapis.com/auth/service.management.readonly", "https://www.googleapis.com/auth/servicecontrol", "https://www.googleapis.com/auth/trace.append"] | ||
} | ||
|
||
zone = "us-east1-b" | ||
} |
Oops, something went wrong.