Skip to content

Commit 33e7b3f

Browse files
committed
TypeScript works with GraphQL
1 parent 4c5df90 commit 33e7b3f

24 files changed

+383
-737
lines changed

Dockerfile

+13-10
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@
22
FROM node:10.15.3-alpine as devBuild
33
WORKDIR /usr/src/app
44

5-
RUN yarn
6-
# Copy the source and build
7-
# Build script uses --dev flag to get the right dependencies
5+
# Log the settings for NPM and Environment variables
6+
RUN npm config ls
7+
RUN env
8+
9+
# Copy the source code and build
810
COPY . .
9-
RUN yarn run build:prod
11+
RUN npm install
12+
RUN npm run build
1013

1114
# PROD BUILD STEP
12-
# Using latest LTS release of Node (comes with Yarn package manager by default)
15+
# Using latest LTS release of Node
1316
FROM node:10.15.3-alpine
1417

1518
# Create an app directory on the container
1619
WORKDIR /usr/src/app
1720
ENV NODE_ENV=production
1821

19-
# Project copy build, install dependencies
20-
COPY --from=devBuild /usr/src/app/build/app ./build/app
21-
COPY package.json yarn.lock README.md ./
22-
RUN yarn install --prod
22+
# Project copy build, install only prod dependencies
23+
COPY --from=devBuild /usr/src/app/dist ./dist
24+
COPY package.json package-lock.json README.md ./
25+
RUN npm install --only=prod
2326

2427
# Install curl to do healthchecks
2528
RUN apk add curl --no-cache
@@ -29,6 +32,6 @@ RUN apk add curl --no-cache
2932
EXPOSE 3000
3033

3134
# Start the application
32-
CMD [ "yarn", "run start:production" ]
35+
CMD npm run start:production
3336

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

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,34 @@ This project is a clone of hacker news rewritten with universal JavaScript, usin
2424

2525
- React - (UI Framework)
2626
- GraphQL - (Web Data API)
27-
- Apollo - (GraphQL Client)
27+
- Apollo - (GraphQL Client/Server)
2828
- Next - (Routing, SSR, Hot Module Reloading, Code Splitting, Build tool uses Webpack)
29-
- Redux - (State Management)
29+
- Webpack - (Module Bundler)
3030
- TypeScript - (Static Types)
31+
- PostCSS - (CSS Processing)
3132
- Node.js - (Web Server)
3233
- Express - (Web App Server)
3334
- Passport - (Authentication)
3435
- Babel - (JS Transpiling)
3536
- TSLint - (JS Best Practices/Code Highlighting)
3637
- Jest - (Tests)
37-
- Yarn Package Manager - (Better Dependencies)
3838
- Docker - (Container Deployment)
3939

40+
- Optional - Yarn or Pnpm Package Manager - (Better Dependencies)
41+
4042
### Benefits
4143

4244
**Front End**
4345

4446
- Declarative UI - (react)
45-
- Flux State Management - (redux)
47+
- Static Typing (typescript)
4648
- GraphQL Fragment Colocation - (react-apollo)
4749
- Prefetch Page Assets - (next)
4850

4951
**Server**
5052

5153
- Universal JS - (node & express)
52-
- Declarative GraphQL Schema - (react-tools)
54+
- Declarative GraphQL Schema - (apollo-server)
5355
- GraphQL Query Batching - (apollo-server-express)
5456
- GraphQL Stored Queries - (apollo-server-express)
5557
- Easy GraphiQL Include - (apollo-server-express)
@@ -63,8 +65,9 @@ This project is a clone of hacker news rewritten with universal JavaScript, usin
6365

6466
- Hot Module Reloading - (next)
6567
- Snapshot Testing - (jest)
68+
- GraphQL Playground
6669
- Faster Package Install - (yarn)
67-
- JS Best Practices - (eslint)
70+
- JS Best Practices - (tslint)
6871

6972
### Architecture Overview
7073

jest.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
setupFilesAfterEnv: ['<rootDir>/test-setup.js'],
5+
snapshotSerializers: ['enzyme-to-json/serializer'],
6+
transform: {
7+
'^.+\\.tsx?$': 'ts-jest',
8+
},
9+
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(test).ts?(x)'],
10+
verbose: true,
11+
};

0 commit comments

Comments
 (0)