Skip to content

Commit

Permalink
remove graphql, fix vercel secrets?
Browse files Browse the repository at this point in the history
  • Loading branch information
hanford committed Jan 3, 2021
1 parent d53d042 commit 1fd404f
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 1,147 deletions.
6 changes: 3 additions & 3 deletions README.md
@@ -1,18 +1,19 @@
## trends

<!--
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=Performance)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=PWA)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=Accessibility)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=Best%20Practices)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=SEO)](https://github.com/ebidel/lighthouse-badge)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100&category=SEO)](https://github.com/ebidel/lighthouse-badge) -->

> browse trending github repos written in your favorite language with this high performance progressive web application
<img src='https://github.com/hanford/trends/blob/master/trends.gif' alt='preview gif' width='600px' />

[View the application](https://trends.now.sh)

Trends is an ultra high performance progressive web application built with React + Next.js and GraphQL. Trends pushes the performance needle forward by only using React on the server and then using the absolute minimum client side code to register a service worker totaling around [~15 lines of code](https://github.com/hanford/trends/blob/master/packages/www/pages/_document.tsx#L92)
Trends is an ultra high performance progressive web application built with Next.js. Trends pushes the performance needle forward by only using React on the server and then using the absolute minimum client side code to register a service worker totaling around [~15 lines of code](https://github.com/hanford/trends/blob/master/packages/www/pages/_document.tsx#L92)

Checkout the perfect performance audit 💯
<img src='https://github.com/hanford/trends/blob/master/audit.jpg' alt='perf audit' width='600px' />
Expand All @@ -25,7 +26,6 @@ Checkout the perfect performance audit 💯
- install prompts on supported platforms
- [15 lines of client side code](https://github.com/hanford/trends/blob/master/packages/www/pages/_document.tsx#L92)
- Server side rendering
- GraphQL
- Next.js
- Now 2.0
- lerna / yarn workspace
Expand Down
12 changes: 7 additions & 5 deletions packages/api/common.tsx
Expand Up @@ -22,18 +22,20 @@ export function formatParams(lang, time) {
order: "desc",
q: "created:>" + key,
per_page: "100",
access_token: process.env.GITHUB_ACCESS_TOKEN
access_token: process.env.GH_ACCESS
})
);

return { key, params };
}

export async function getRepos(searchParams) {
const res = await fetch(
`https://api.github.com/search/repositories?${searchParams}`,
{ headers: { Accept: "application/vnd.github.preview" } }
);
const url = `https://api.github.com/search/repositories?${searchParams}`;

const res = await fetch(url, {
headers: { Accept: "application/vnd.github.preview" }
});

const data = await res.json();
const items = await data.items;

Expand Down
58 changes: 0 additions & 58 deletions packages/api/graphql.tsx

This file was deleted.

12 changes: 6 additions & 6 deletions packages/api/index.tsx
@@ -1,25 +1,25 @@
import { ApolloServer } from "apollo-server-express";
import express from "express";
import cors from "cors";

import schema from "./graphql";
import { formatParams, getRepos } from "./common";

const port = parseInt(process.env.PORT || "2999", 10) || 2999;

const server = new ApolloServer({ schema, introspection: true });
const app = express();

app.use(cors());
server.applyMiddleware({ app, path: "/api/graphql", cors: true });

app.get("/", async (_req, res) => {
return res.sendStatus(200);
});

app.get("/api/repos", async (req, res) => {
const { language, time = 7 } = req.query;
const { params } = formatParams(language, time);

const repos = await getRepos(params);
const items = await getRepos(params);

return res.send({ items: repos });
return res.send({ items });
});

app.listen(port, (err: Error) => {
Expand Down
7 changes: 1 addition & 6 deletions packages/api/package.json
Expand Up @@ -9,23 +9,18 @@
"ncc": "ncc"
},
"dependencies": {
"apollo-server-core": "^2.3.1",
"apollo-server-express": "^2.3.1",
"@vercel/ncc": "^0.26.1",
"cors": "^2.8.5",
"express": "^4.16.3",
"graphql": "0.13.2",
"graphql-tools": "^4.0.3",
"isomorphic-fetch": "^2.2.1",
"lru-cache": "^5.1.1",
"querystring": "^0.2.0"
},
"devDependencies": {
"@types/express": "^4.16.0",
"@types/graphql": "^14.0.3",
"@types/isomorphic-fetch": "0.0.34",
"@types/lru-cache": "^4.1.1",
"@types/node": "^10.12.15",
"@zeit/ncc": "^0.5.3",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.17.0",
"typescript": "^4.1.3"
Expand Down

0 comments on commit 1fd404f

Please sign in to comment.