Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Merge branches 'develop' and 'master' of https://github.com/htdangkho…
Browse files Browse the repository at this point in the history
  • Loading branch information
htdangkhoa committed Dec 21, 2019
2 parents a321939 + b93e1cd commit f9e5998
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"jest": "^24.9.0",
"jest-css-modules": "^2.1.0",
"lodash-webpack-plugin": "^0.11.5",
"mini-css-extract-plugin": "^0.8.0",
"mini-css-extract-plugin": "^0.9.0",
"nodemon": "^2.0.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss": "^7.0.25",
Expand Down
8 changes: 2 additions & 6 deletions src/client/pages/Introduce/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export const projects = [
{
pinned: false,
source: `
**8days | Jun, 2017 - Jul, 2018 | ${download(
'https://play.google.com/store/apps/details?id=co.vn.the8days&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1',
)}**
**8days | Jun, 2017 - Jul, 2018**
\`Android\` / \`GraphQL\` / \`AES En-Decryption\` / \`AWS\`
Application is a solution to help worker at factory can other food using QR Code technology.
- Analysis
Expand All @@ -152,9 +150,7 @@ export const projects = [
{
pinned: false,
source: `
**Recpic | Apr, 2016 - May, 2017 | ${download(
'https://play.google.com/store/apps/details?id=com.codeatnite.recpic',
)}**
**Recpic | Apr, 2016 - May, 2017**
\`Ionic\` / \`Android\` / \`iOS\` / \`HTML\` / \`SCSS\` / \`Javascript\`
This is the app that helps people to manage their spending.
- Development
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/NotFound/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Layout from 'components/Layout';
import './styles.scss';

const NotFound = ({ route: { title }, staticContext = {} }) => {
staticContext.status = 404;
staticContext.status = '404';

return (
<Layout title={title} className='not__found__container' needLogin={false}>
Expand Down
32 changes: 13 additions & 19 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,12 @@ app.use('/api', serverErrorMiddleware());
app.use('/api', notFoundErrorMiddleware());

app.get('/*', async (req: Request, res: Response) => {
const context = {
status: 404,
};

const { store } = configureStore({ url: req.url });

const loadBranchData = (): Promise<any> => {
const branches = matchRoutes(routes, req.path);

const promises = branches.map(({ route, match }) => {
if (match.path === req.path && match.isExact) {
context.status = 200;
}

if (route.loadData) {
return Promise.all(
route
Expand All @@ -89,6 +81,8 @@ app.get('/*', async (req: Request, res: Response) => {
try {
await loadBranchData();

const context = {};

const statsFile = resolve(process.cwd(), 'public/loadable-stats.json');

const extractor = new ChunkExtractor({ statsFile });
Expand All @@ -107,19 +101,9 @@ app.get('/*', async (req: Request, res: Response) => {
</ChunkExtractorManager>
);

if (context.url) {
res.status(301).setHeader('location', context.url);

return res.end();
}

const status = context.status === 404 ? 404 : 200;

const initialState = store.getState();

const body = [];

return ReactDOMServer.renderToNodeStream(App)
return ReactDOMServer.renderToStaticNodeStream(App)
.on('data', (chunk) => {
body.push(chunk.toString());
})
Expand All @@ -129,6 +113,16 @@ app.get('/*', async (req: Request, res: Response) => {
.on('end', () => {
const htmlContent = body.join('');

if (context.url) {
res.status(301).setHeader('location', context.url);

return res.end();
}

const status = context.status === '404' ? 404 : 200;

const initialState = store.getState();

const head = Helmet.renderStatic();

return res
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8988,10 +8988,10 @@ mini-css-extract-plugin@^0.7.0:
schema-utils "^1.0.0"
webpack-sources "^1.1.0"

mini-css-extract-plugin@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#81d41ec4fe58c713a96ad7c723cdb2d0bd4d70e1"
integrity sha512-MNpRGbNA52q6U92i0qbVpQNsgk7LExy41MdAlG84FeytfDOtRIf/mCHdEgG8rpTKOaNKiqUnZdlptF469hxqOw==
mini-css-extract-plugin@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.0.tgz#47f2cf07aa165ab35733b1fc97d4c46c0564339e"
integrity sha512-lp3GeY7ygcgAmVIcRPBVhIkf8Us7FZjA+ILpal44qLdSu11wmjKQ3d9k15lfD7pO4esu9eUIAW7qiYIBppv40A==
dependencies:
loader-utils "^1.1.0"
normalize-url "1.9.1"
Expand Down

0 comments on commit f9e5998

Please sign in to comment.