Giter Club home page Giter Club logo

postlist-react-ssr-koa-webpack's Introduction

A Sample App that displays a list of posts

Technologies Used

  • Typescript
  • React
  • Webpack
  • Babel
  • Koa
  • FBT (facebook translations)

HTML Streaming Support

The app does server side streaming using:

  • Multistream
  • String to Stream
  • renderToNodeStream (React)

Translations for

  • English
  • French
  • Japanese

Running the App

Note: Required minimum node version is 12

  1. Clone the repository by running git clone [email protected]:aprabhudesai/postlist-react-ssr-koa-webpack.git
  2. Run cd postlist-react-ssr-koa-webpack/
  3. Install dependencies npm install
  4. Generate translations (FBT) npm run build:fbt
  5. Open 2 terminal tabs.
    • In one tab run the build in watch mode npm run build
    • In second tab start the server npm run watch-server. Make sure you are running node version 12 or above
  6. You can access the application at http://localhost:8088. To specify locale add the URL param locale. For e.g.
    • http://localhost:8088/?locale=en_US
    • http://localhost:8088/?locale=fr_FR
    • http://localhost:8088/?locale=ja_JP

Load testing the App

Using curl command (preferred)

  1. Open 3 terminals and run the following:

    • ./test/loadtest-fbt.sh en_US 100
    • ./test/loadtest-fbt.sh fr_FR 100
    • ./test/loadtest-fbt.sh ja_JP 100

    If you get file permissions error please run chmod +x loadtest-fbt.sh

Using loadtest package

  1. Open a new terminal
  2. Run the command npm run loadtest:fbt

Current Issue with FBT

In the terminal(s) that you execute the load test commands, you should see the html being returned from server. You have to observe two things:

  • <html lang"<locale>"> - which has the locale we specified in our loadtest
  • the translated text sent back in the HTML

For e.g. In one of the runs I saw this:

  • html lang=fr_FR
  • HTML returned is in japanese:
    <html lang=fr_FR>
        <head>
           <link rel="stylesheet" href="main.css"/>
           <style>#root {
              display: flex;
              justify-content: center;
              }
           </style>
        </head>
        <body>
           <div id="root">
              <div class="post-list" data-reactroot="">
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは最初の投稿です</div>
                       <div>その日の最初の投稿.</div>
                    </div>
                 </div>
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは2番目の投稿です</div>
                       <div>その日の2番目のポスト.</div>
                    </div>
                 </div>
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは3番目の投稿です</div>
                       <div>今日のThridポスト.</div>
                    </div>
                 </div>
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは4番目の投稿です</div>
                       <div>今日の4番目のポスト.</div>
                    </div>
                 </div>
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは5番目の投稿です</div>
                       <div>今日の5番目のポスト.</div>
                    </div>
                 </div>
                 <div class="post">
                    <div class="col1"><img class="icon" src="img/post_image.jpg"/></div>
                    <div class="col2">
                       <div>これは6番目の投稿です</div>
                       <div>今日の6番目のポスト.</div>
                    </div>
                 </div>
              </div>
           </div>
        </body>
        <script src="js/client.js"></script>
     </html>
    

postlist-react-ssr-koa-webpack's People

Contributors

aprabhudesai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.