Skip to content

Commit

Permalink
Portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali0NAL committed Dec 28, 2024
1 parent 3632a33 commit 0ebaec9
Show file tree
Hide file tree
Showing 127 changed files with 24,161 additions and 0 deletions.
603 changes: 603 additions & 0 deletions .all-contributorsrc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.4" # Use the sha or tag you want to point at
hooks:
- id: prettier
files: ".*.(json|js|css)"


4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/serviceWorker.js
package-lock.json
src/assets/lottie

11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"singleQuote": false,
"printWidth": 80,
"useTabs": false,
"tabWidth": 2,
"semi": true
}

29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is the main docker file configurations

# Official Node JS runtime as a parent image
FROM node:20.0-alpine

# Set the working directory to ./app
WORKDIR /app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package.json ./

RUN apk add --no-cache git

# Install any needed packages
RUN npm install

# Audit fix npm packages
RUN npm audit fix

# Bundle app source
COPY . /app

# Make port 3000 available to the world outside this container
EXPOSE 3000

# Run app.js when the container launches
CMD ["npm", "start"]
12 changes: 12 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// README
// This is only a .env example
// Do not change this file, adding your GITHUB TOKEN here!
// Use cp or mv (like this: cp env.example .env), then edit .env with your GITHUB TOKEN.
// IMPORTANT: Don't forget to add to update your .gitignore with .env (to avoid making your key public!)

REACT_APP_GITHUB_TOKEN = "YOUR GITHUB TOKEN HERE"
GITHUB_USERNAME = "YOUR GITHUB USERNAME HERE"
// Set to true to fetch profile data from GitHub (remember to remove all components relying on GitHub data if set to false)
USE_GITHUB_DATA = "true"
// Set to your username in order to fetch blog data from Medium (otherwise, hardcoded values from Blogs.js are used)
MEDIUM_USERNAME = "YOU MEDIUM USERNAME HERE"
130 changes: 130 additions & 0 deletions fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
fs = require("fs");
const https = require("https");
process = require("process");
require("dotenv").config();

const GITHUB_TOKEN = process.env.REACT_APP_GITHUB_TOKEN;
const GITHUB_USERNAME = process.env.GITHUB_USERNAME;
const USE_GITHUB_DATA = process.env.USE_GITHUB_DATA;
const MEDIUM_USERNAME = process.env.MEDIUM_USERNAME;

const ERR = {
noUserName:
"Github Username was found to be undefined. Please set all relevant environment variables.",
requestFailed:
"The request to GitHub didn't succeed. Check if GitHub token in your .env file is correct.",
requestFailedMedium:
"The request to Medium didn't succeed. Check if Medium username in your .env file is correct."
};
if (USE_GITHUB_DATA === "true") {
if (GITHUB_USERNAME === undefined) {
throw new Error(ERR.noUserName);
}

console.log(`Fetching profile data for ${GITHUB_USERNAME}`);
var data = JSON.stringify({
query: `
{
user(login:"${GITHUB_USERNAME}") {
name
bio
avatarUrl
location
pinnedItems(first: 6, types: [REPOSITORY]) {
totalCount
edges {
node {
... on Repository {
name
description
forkCount
stargazers {
totalCount
}
url
id
diskUsage
primaryLanguage {
name
color
}
}
}
}
}
}
}
`
});
const default_options = {
hostname: "api.github.com",
path: "/graphql",
port: 443,
method: "POST",
headers: {
Authorization: `Bearer ${GITHUB_TOKEN}`,
"User-Agent": "Node"
}
};

const req = https.request(default_options, res => {
let data = "";

console.log(`statusCode: ${res.statusCode}`);
if (res.statusCode !== 200) {
throw new Error(ERR.requestFailed);
}

res.on("data", d => {
data += d;
});
res.on("end", () => {
fs.writeFile("./public/profile.json", data, function (err) {
if (err) return console.log(err);
console.log("saved file to public/profile.json");
});
});
});

req.on("error", error => {
throw error;
});

req.write(data);
req.end();
}

if (MEDIUM_USERNAME !== undefined) {
console.log(`Fetching Medium blogs data for ${MEDIUM_USERNAME}`);
const options = {
hostname: "api.rss2json.com",
path: `/v1/api.json?rss_url=https://medium.com/feed/@${MEDIUM_USERNAME}`,
port: 443,
method: "GET"
};

const req = https.request(options, res => {
let mediumData = "";

console.log(`statusCode: ${res.statusCode}`);
if (res.statusCode !== 200) {
throw new Error(ERR.requestMediumFailed);
}

res.on("data", d => {
mediumData += d;
});
res.on("end", () => {
fs.writeFile("./public/blogs.json", mediumData, function (err) {
if (err) return console.log(err);
console.log("saved file to public/blogs.json");
});
});
});

req.on("error", error => {
throw error;
});

req.end();
}
Loading

0 comments on commit 0ebaec9

Please sign in to comment.