@@ -8,7 +8,6 @@ "dependencies": { "@babel/core": "^7.18.5", "@next/bundle-analyzer": "^12.1.6", "isomorphic-unfetch": "^3.1.0", "next": "^12.1.6", "next-compose-plugins": "^2.2.1", "react": "^18.2.0",
@@ -1,7 +1,6 @@import React from "react";import styled, { keyframes } from "styled-components";import PropTypes from "prop-types";import "isomorphic-unfetch";import Page from "../components/page";
@@ -203,33 +202,105 @@ const Code = ({ commits }) => { );};Code.getInitialProps = async () => { const baseUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://isaacbythewood.com"; const commits = await fetch(`${baseUrl}/api/code`).then((res) => res.json()); return { commits: commits,export async function getServerSideProps(context) { // NOTE: We eval the require on purpose so that webpack doesn't bundle it const { Sequelize } = eval("require('sequelize')"); const sequelize = new Sequelize("sqlite://db.sqlite3"); const Commit = sequelize.define("commit", { repo: { type: Sequelize.STRING, allowNull: false, }, createdAt: { type: Sequelize.DATE, allowNull: false, }, data: { type: Sequelize.JSON, allowNull: false, }, }); const getCommit = async (repo) => { const storedCommit = await Commit.findOne({ where: { repo, createdAt: { [Sequelize.Op.gte]: new Date(Date.now() - 24 * 60 * 60 * 1000), }, }, }); if (storedCommit) { return storedCommit; } const commitsFetch = await fetch( `https://api.github.com/repos/overshard/${repo}/commits` ); const commits = await commitsFetch.json(); const commit = commits[0]; const commitData = { repo: repo, createdAt: new Date(), data: { sha: commit.sha, commit: { message: commit.commit.message, date: commit.commit.author.date, }, author: { name: commit.commit.author.name, email: commit.commit.author.email, }, }, }; await Commit.create(commitData); return commitData; }; const getCommits = async () => { const alpinefiles = await getCommit("alpinefiles"); const analytics = await getCommit("analytics"); const blog = await getCommit("blog"); const dockerfiles = await getCommit("dockerfiles"); const dotfiles = await getCommit("dotfiles"); const isaacbythewood = await getCommit("isaacbythewood.com"); const status = await getCommit("status"); const timelite = await getCommit("timelite"); const timestrap = await getCommit("timestrap"); return { alpinefiles: alpinefiles, analytics: analytics, blog: blog, dockerfiles: dockerfiles, dotfiles: dotfiles, isaacbythewood: isaacbythewood, status: status, timelite: timelite, timestrap: timestrap, }; }; await Commit.sync(); return getCommits().then((commits) => { return { props: { commits: JSON.parse(JSON.stringify(commits)), }, }; });};Code.propTypes = { commits: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), commits: PropTypes.object,};export default Code;const FadeIn = keyframes` 0% { opacity: 0; } 100% { opacity: 1; }`;const TransformRight = keyframes` from { transform: scaleX(0);
@@ -1777,14 +1777,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==isomorphic-unfetch@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz#87341d5f4f7b63843d468438128cb087b7c3e98f" integrity sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q== dependencies: node-fetch "^2.6.1" unfetch "^4.2.0"jest-worker@^27.4.5: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0"
@@ -2100,7 +2092,7 @@ node-addon-api@^5.0.0: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.0.0.tgz#7d7e6f9ef89043befdb20c1989c905ebde18c501" integrity sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==node-fetch@^2.6.1, node-fetch@^2.6.7:node-fetch@^2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
@@ -2918,11 +2910,6 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2"unfetch@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be" integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==unique-filename@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230"