Skip to content

Instantly share code, notes, and snippets.

View fardeen9983's full-sized avatar
🌚
I have the Power

Fardeen Khan fardeen9983

🌚
I have the Power
View GitHub Profile
@fardeen9983
fardeen9983 / README.md
Last active April 13, 2019 19:07
Following the tutorial on freeCodeCamp.org Node.js FULL TUTORIAL : https://www.youtube.com/watch?v=RLtyhwFtXQA
  • Initiate the node project npm init
  • Create app.js
  • Write console logs and run
@fardeen9983
fardeen9983 / FileUploadService.cs
Last active March 31, 2022 11:56
File Upload Service
/// <summary>
/// Generates a presigned URL of the file if it is successfully uploaded to S3
/// </summary>
/// <param name="file">File to be Uploaded</param>
/// <returns></returns>
public async Task<string> GetS3ObjectPresignedUrl(IFormFile file)
{
try
{
var key = Path.GetRandomFileName() + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName).ToLowerInvariant();
@fardeen9983
fardeen9983 / UploadController.cs
Created March 31, 2022 12:05
Expose FileUploadService
namespace CodePanthers.AWS.S3.UploadService.Controllers
{
[Route("Upload")]
public class UploadController : Controller
{
private readonly IFileUploadService _fileUploadService;
public UploadController(IFileUploadService fileUploadService)
{
_fileUploadService = fileUploadService;
}
@fardeen9983
fardeen9983 / SNSAccessPolicy.json
Created April 13, 2022 10:32
SNS Access Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"sns:Publish",
"sns:Subscribe"
],
@fardeen9983
fardeen9983 / INotificationService.cs
Created April 13, 2022 11:53
Notification Service Interface
using System.Threading.Tasks;
namespace CodePanthers.AWS.S3.UploadService.Services
{
public interface INotificationService
{
Task SendUploadNotification(string topic, string message);
Task SendUploadNotification(string message);
Task RegisterSubscirption(string email);
Task RegisterSubscirption(string topic, string email);
@fardeen9983
fardeen9983 / NotificationService.cs
Created April 13, 2022 11:56
Notification Service Implementation
using Amazon.SimpleNotificationService;
using Amazon.SimpleNotificationService.Model;
using Microsoft.Extensions.Configuration;
using System;
using System.Threading.Tasks;
namespace CodePanthers.AWS.S3.UploadService.Services
{
public class NotificationService : INotificationService
{
@fardeen9983
fardeen9983 / FileUploadService.cs
Last active April 13, 2022 12:04
Updated Pre-signed URL method
public async Task<string> GetS3ObjectPresignedUrl(IFormFile file)
{
try
{
var key = Path.GetRandomFileName() + Guid.NewGuid().ToString() + Path.GetExtension(file.FileName).ToLowerInvariant();
if (await UploadFileToS3(file, key))
{
var getUrlRequest = new GetPreSignedUrlRequest
{
BucketName = BucketName,
@fardeen9983
fardeen9983 / UploadController.cs
Created April 13, 2022 12:07
Register Email Action
[HttpPost("register")]
public async Task<IActionResult> RegisterEmailSubscription([FromBody] string email)
{
if (string.IsNullOrEmpty(email))
{
return BadRequest(new { status = "Failed", message = "Enter a valid Email Address" });
}
else
{
await _notificationService.RegisterSubscirption(email);
@fardeen9983
fardeen9983 / .gitignore
Created April 14, 2022 17:29
Node.js GitIgnore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
@fardeen9983
fardeen9983 / app.js
Created April 14, 2022 17:33
Simple Express Server
const express = require("express");
const app = express();
const PORT = process.env.PORT || 80;
app.get("/",(req,res)=> {
res.send("Hello From Code Panthers");
res.end();
})
app.listen(PORT,() => {