Skip to content

Commit b4d5567

Browse files
committed
Changed project to typescript
1 parent 5928e11 commit b4d5567

File tree

418 files changed

+22945
-10102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

418 files changed

+22945
-10102
lines changed

.babelrc

-20
This file was deleted.

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# DEV BUILD STEP
2-
FROM node:8.7-alpine as devBuild
2+
FROM node:10.15.3-alpine as devBuild
33
WORKDIR /usr/src/app
44

55
RUN yarn
@@ -10,7 +10,7 @@ RUN yarn run build:prod
1010

1111
# PROD BUILD STEP
1212
# Using latest LTS release of Node (comes with Yarn package manager by default)
13-
FROM node:8.7-alpine
13+
FROM node:10.15.3-alpine
1414

1515
# Create an app directory on the container
1616
WORKDIR /usr/src/app
@@ -29,6 +29,6 @@ RUN apk add curl --no-cache
2929
EXPOSE 3000
3030

3131
# Start the application
32-
CMD [ "yarn", "start" ]
32+
CMD [ "yarn", "run start:production" ]
3333

3434
HEALTHCHECK CMD curl --silent --fail http://localhost:3000/ || exit 1

README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</p>
99

1010
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.
11+
1112
<p align="center" margin-bottom="0">
1213
<a href="http://www.hnclone.win" target="_blank">
1314
<img alt="Hacker News Clone Demo" width="auto" height="auto" src="docs/HN-Demo.jpg">
@@ -20,30 +21,33 @@ This project is a clone of hacker news rewritten with universal JavaScript, usin
2021
## Overview
2122

2223
### Featuring
24+
2325
- React - (UI Framework)
2426
- GraphQL - (Web Data API)
2527
- Apollo - (GraphQL Client)
2628
- Next - (Routing, SSR, Hot Module Reloading, Code Splitting, Build tool uses Webpack)
2729
- Redux - (State Management)
30+
- TypeScript - (Static Types)
2831
- Node.js - (Web Server)
2932
- Express - (Web App Server)
3033
- Passport - (Authentication)
3134
- Babel - (JS Transpiling)
32-
- Flow - (Static Types)
33-
- ESLint - (JS Best Practices/Code Highlighting)
35+
- TSLint - (JS Best Practices/Code Highlighting)
3436
- Jest - (Tests)
3537
- Yarn Package Manager - (Better Dependencies)
3638
- Docker - (Container Deployment)
3739

3840
### Benefits
3941

4042
**Front End**
43+
4144
- Declarative UI - (react)
4245
- Flux State Management - (redux)
4346
- GraphQL Fragment Colocation - (react-apollo)
4447
- Prefetch Page Assets - (next)
4548

4649
**Server**
50+
4751
- Universal JS - (node & express)
4852
- Declarative GraphQL Schema - (react-tools)
4953
- GraphQL Query Batching - (apollo-server-express)
@@ -56,34 +60,34 @@ This project is a clone of hacker news rewritten with universal JavaScript, usin
5660
- Container Based Runtime - (docker)
5761

5862
**Dev/Test**
63+
5964
- Hot Module Reloading - (next)
6065
- Snapshot Testing - (jest)
6166
- Faster Package Install - (yarn)
6267
- JS Best Practices - (eslint)
6368

64-
6569
### Architecture Overview
6670

6771
<p align="center">
6872
<img alt="Hacker News Clone Architecture Overview" width="auto" height="400px" src="docs/HN-Clone-Architecture-overview.png">
6973
</p>
7074

71-
*Server.js* is the entry point. It uses Express and passes requests to Next. Next SSR renders the pages using ```getInitialProps()``` hook from Apollo helper. Therefore the app makes GraphQL requests on the client or server.
75+
_Server.js_ is the entry point. It uses Express and passes requests to Next. Next SSR renders the pages using `getInitialProps()` hook from Apollo helper. Therefore the app makes GraphQL requests on the client or server.
7276

73-
When the client receives the page it preloads next page JS designated with ```<Link prefetch href="/">```. When the client navigates to the linked page it only needs to make a GraphQL query to render. *Great!*
77+
When the client receives the page it preloads next page JS designated with `<Link prefetch href="/">`. When the client navigates to the linked page it only needs to make a GraphQL query to render. _Great!_
7478

7579
See more: <a href="https://github.com/zeit/next.js/">Next.js</a>,
7680
<a href="http://dev.apollodata.com/react/">Apollo GraphQL Client</a>
7781

78-
GraphQL: <a href="http://dev.apollodata.com/tools/graphql-tools/index.html">GraphQL-Tools by Apollo</a>
82+
GraphQL: <a href="http://dev.apollodata.com/tools/graphql-tools/index.html">GraphQL-Tools by Apollo</a>
7983
or
8084
<a href="http://graphql.org/graphql-js/">GraphQL docs</a>
8185

8286
### Directory Structure
8387

8488
Each directory contains a README.
8589

86-
*root* - Only contains config files such as Babel, ESLint, Docker, Flow, NPM, Yarn, Git.
90+
_root_ - Only contains config files such as Babel, ESLint, Docker, Flow, NPM, Yarn, Git.
8791

8892
## How To Start
8993

@@ -95,7 +99,7 @@ You can download and run the repo with one command to rule them all:
9599

96100
### Setup
97101

98-
Running the app in dev mode is fully featured including *hot module reloading*:
102+
Running the app in dev mode is fully featured including _hot module reloading_:
99103

100104
`npm install`
101105

@@ -107,7 +111,7 @@ To run in production mode:
107111

108112
### Configuration
109113

110-
The project runs out of the box with default settings (*/src/config.js*). 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*.
114+
The project runs out of the box with default settings (_/src/config.js_). 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_.
111115

112116
## How To Test
113117

@@ -119,23 +123,23 @@ This project uses Jest and can do snapshot testing of React components. Whenever
119123

120124
## How To Build For Deployment
121125

122-
`npm run build`: NextJS app with entry point *server.js* that uses Node.js/Express. Uses Babel compiler to transpile project src to build.
126+
`npm run build`: NextJS app with entry point _server.js_ that uses Node.js/Express. Uses Babel compiler to transpile project src to build.
123127

124128
OR
125129

126130
`npm run build-docker`
127131
Docker Container: Builds a docker container using Dockerfile.
128132

129-
130133
#### Static Website (Optional)
131134

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

134-
`npm run build-static-website`: Builds static website to */build/static*. Use a static web server *eg.* NGINX/Github Pages.
135-
137+
`npm run build-static-website`: Builds static website to _/build/static_. Use a static web server _eg._ NGINX/Github Pages.
136138

137139
## Contributing
140+
138141
Pull requests are welcome. File an issue for ideas, conversation or feedback.
139142

140143
### Community
144+
141145
After you ★Star this project, follow [@ClintonDAnnolfo](https://twitter.com/clintondannolfo) on Twitter.

babel.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(module.exports = api => {
2+
api.cache(true);
3+
return {
4+
"presets": ["next/babel", "@zeit/next-typescript/babel"],
5+
"plugins": [
6+
"@babel/proposal-class-properties",
7+
"@babel/proposal-object-rest-spread",
8+
[
9+
"transform-define",
10+
{
11+
"process.env.NODE_ENV": process.env.NODE_ENV
12+
}
13+
]
14+
]
15+
};
16+
})

dist/components/container/NewsDetailWithData.js

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsDetailWithData.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsFeedWithApolloRenderer.js

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsFeedWithApolloRenderer.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsItemWithApolloRenderer.js

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsItemWithApolloRenderer.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsTitleWithData.js

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/container/NewsTitleWithData.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/presentational/Comment.js

+68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)