MIT License

项目介绍

clintonwoo/hackernews-react-graphql 是一个托管在 GitHub 上的开源项目,主要使用 TypeScript 编写,采用 MIT License 许可证,目前获得 4.4k 个 Star、536 次 Fork。

仓库全名
clintonwoo/hackernews-react-graphql
开源许可证
MIT License
Star 数
4.4k
Fork 数
536
未关闭 Issue
6

README 摘要

Hacker News Clone React/GraphQL This project is a clone of hacker news rewritten with universal JavaScript, using React and GraphQL. It is intended to be an example or boilerplate to help you structure your projects using production-ready technologies. Live Demo Overview Featuring React - (UI Framework) GraphQL - (Web Data API) Apollo - (GraphQL Client/Server) Next - (Routing, SSR, Hot Module Reloading, Code…

完整内容见 GitHub 原始 README 或本页 。

常见问题

hackernews-react-graphql 用什么语言开发?

主要使用 TypeScript 编写,采用 MIT License 许可证,目前有 4.4k 个 Star。

hackernews-react-graphql 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 hackernews-react-graphql 的源码?

可以直接克隆仓库:git clone https://github.com/clintonwoo/hackernews-react-graphql.git,默认分支为 master;安装与运行步骤见仓库 README。

hackernews-react-graphql 最近还在维护吗?

仓库最近一次更新为 2023年3月4日,当前有 6 个未关闭 Issue;Star 数为 4.4k,可作为社区活跃度的参考。

简要分析

热度分
5591
价值分
2834
活跃状态
活跃

语言占比

CSS
Dockerfile
JavaScript
TypeScript

README

Hacker News Clone React/GraphQL

GitHub Stars GitHub Followers GitHub Issues GitHub Pull Requests

This project is a clone of hacker news rewritten with universal JavaScript, using React and GraphQL. It is intended to be an example or boilerplate to help you structure your projects using production-ready technologies.

Hacker News Clone Demo

Live Demo

Overview

Featuring

  • React - (UI Framework)

  • GraphQL - (Web Data API)

  • Apollo - (GraphQL Client/Server)

  • Next - (Routing, SSR, Hot Module Reloading, Code Splitting, Build tool uses Webpack)

  • TypeScript - (Static Types)

  • Webpack - (Module Bundler)

  • PostCSS - (CSS Processing)

  • Node.js - (Web Server)

  • Express - (Web App Server)

  • Passport - (Authentication)

  • ESLint - (Coding Best Practices/Code Highlighting)

  • Jest - (Tests)

  • Docker - (Container Deployment)

  • Optional - Yarn or Pnpm Package Manager - (Better Dependencies)

Benefits

Front End

  • Declarative UI - (react)
  • Static Typing (typescript)
  • GraphQL Fragment Colocation - (@apollo/client)
  • Prefetch Page Assets - (next)

Server

  • Universal JS - (node & express)
  • Declarative GraphQL Schema - (apollo-server)
  • GraphQL Query Batching - (apollo-server-express)
  • GraphQL Stored Queries - (apollo-server-express)
  • Easy GraphiQL Include - (apollo-server-express)
  • Local Authentication Strategy - (passport)
  • Server Side Rendering - (next)
  • Code Splitting - (next)
  • Build to Static Website - (next)
  • Container Based Runtime - (docker)

Dev/Test

  • Hot Module Reloading - (next)
  • Snapshot Testing - (jest)
  • GraphQL Playground - (apollo-server-express)
  • Faster Package Install - (pnpm/yarn)
  • JS/TS Best Practices - (eslint)

Architecture Overview

Hacker News Clone Architecture Overview

server.ts is the entry point. It uses Express and passes requests to Next. Next SSR renders the pages using getServerSideProps() hook from Apollo helper. Therefore the app makes GraphQL requests on the client or server.

When the client loads the page it preloads next pages code from any <Link href="/">. When the client navigates to the next page it only needs to make one GraphQL query to render. Great!

See more: Next.js, Apollo GraphQL Client

GraphQL: GraphQL-Tools by Apollo or GraphQL docs

Directory Structure

Each web page has a React component in pages. Server code is in server. Shared code that runs on client or server is in src. Do not import from server or pages in src to avoid running code in the wrong environment.

The project root contains config files such as TypeScript, Babel, ESLint, Docker, Flow, NPM, Yarn, Git.

How To Start

One Click Download & Run

You can download and run the repo with one command to rule them all:

git clone https://github.com/clintonwoo/hackernews-react-graphql.git && cd hackernews-react-graphql && npm install && npm start

Setup

Running the app in dev mode is fully featured including hot module reloading:

npm install

npm start

To run in production mode:

npm run build:prod && npm run start:prod

Configuration

The project runs out of the box with default settings (/src/config.ts). You can include a .env file in your project root to configure settings (this is the ‘dotenv’ npm package). The .env file is included in .gitignore.

How To Test

Jest

npm test

This project uses Jest and can do snapshot testing of React components. Whenever a component is changed, please update the snapshots using npm test -- -u or npx jest --updateSnapshot.

How To Build For Deployment

npm run build:prod: NextJS app with entry point server.ts that uses Node.js/Express. Uses TypeScript compiler to transpile project src to build.

OR

npm run build-docker Docker Container: Builds a docker container using Dockerfile.

Static Website (Optional)

NextJS lets us make a powerful static website but you need to consider if you need server side rendering.

npm run build-static-website: Builds static website to /build/static. Use a static web server eg. NGINX/Github Pages.

Contributing

Pull requests are welcome. File an issue for ideas, conversation or feedback.

Community

After you ★Star this project, follow @ClintonDAnnolfo on Twitter.

评论

暂无评论