node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

@dollarshaveclub/face-country-picker

Face Country Picker

CircleCI codecov Docker Repository on Quay

This project was bootstrapped with Create React App, then inlined using yarn eject. Many additional features were added:

  • A server was added using Jest as the testing framework as well
    • Removed the default options for a static build
  • CSS modules were added, working both client-side and server-side
  • Server-side rendering was added
  • SASS support was added for dapper
  • Docker
  • Update babel
    • Use transform-runtime in babel for smaller builds
    • Server-side CSS modules
    • When publishing, babel compiles all source files so that babel is in memory at runtime
  • standard for eslint rules
  • The compiled files are published to npm to make usage as a module easier

API

Currently, this is exported as an API so that it can be mounted in another nodejs server.

render(options)

const renderCountryPicker = require('@dollarshaveclub/face-country-picker/dist/server/render');
 
app.use('/shop/choose', (req, res) => {
  res.setHeader('Cache-Control', 'public, max-age=3600');
  res.send(renderCountryPicker.default({
    prefix: '/face-web',
    hostname: req.hostname,  
  }));
});

Options are:

  • prefix
  • hostname

Static Folder

app.use('/static', express.static(path.resolve(__dirname, '../node_modules/@dollarshaveclub/face-country-picker/dist/build/static'), {
  maxAge: '1 day',
}));

Commands

  • PORT=3100 npm start - start the webpack and backend server for development.
    • NOTE: go to http://localhost:3100, not the hostname displayed in the console
  • npm test - run all tests
  • npm run test-server - test the backend server
  • npm run test-jsdom - test the react components using jsdom
  • npm run release - build the dist/ folder. Run this before publishing.

Publishing

  • npm run release - build the dist/ folder. Run this before publishing.
  • npm version [major|minor|patch] - update the version
  • git push origin master <version> - push master and the tag to git
  • npm publish - public the version. NOTE: you may need npm publishing rights

The published version of the app is a little different than the dev version. To test the published version of the app:

  • npm run release
  • PORT=3100 NO_BABEL=1 node dist/server