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 / main.yml
Created April 17, 2022 14:25
Github action
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
@fardeen9983
fardeen9983 / tutorial.codepanthers.com.conf
Created April 17, 2022 11:15
Node Github Actions Nginx Conf
upstream nodejs_upstream{
server 127.0.0.1:3000;
keepalive 64;
}
server {
listen 80;
server_name tutorial.codepanthers.com;
location / {
@fardeen9983
fardeen9983 / FileUploadService.cs
Last active April 15, 2022 20:56
CloudFront Signed URL Generation
private string GetPrivateUrl(string file)
{
try
{
return
AmazonCloudFrontUrlSigner.GetCannedSignedURL(
"https://" + CloudFrontDomain + "/" + file,
new StreamReader(@"PrivateKey.pem"),
CloudFrontKeyId,
DateTime.Now.AddDays(7)
@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,() => {
@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 / 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 / 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 / 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 / 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 / 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"
],