Giter Club home page Giter Club logo

boilerplate-nutella's People

Contributors

ialaddin avatar pedrobullo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

boilerplate-nutella's Issues

Set cache-control on static route

It may be a good idea to set cache on the static files.

app.use(Express.static(process.env.RAZZLE_PUBLIC_DIR, { maxAge: 0 }));

app.use((_, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET,POST,PUT,OPTIONS,PATCH,DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type,Authorization');
  res.header('Cache-Control', 'no-cache, private');
  next();
});

Change the way of setting the PORT on server

Based on that issue jaredpalmer/razzle#356 I found a way to change the port by using the process.env.

const getEnv = c => process.env[c];
const PORT = getEnv('PORT');

export default Loadable.preloadAll()
  .then(() => express()
    .use((req, res) => server.handle(req, res))
    .listen(PORT, (err) => {
      if (err) {
        console.error(err);
        return;
      }
      console.log(`🤰 Running at: http://localhost:${PORT}/.`);
    })
  );

Implement gzip compression

A good option is https://github.com/expressjs/compression

// Apply body Parser and server public assets and routes
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use((_, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET,POST,PUT,OPTIONS,PATCH,DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type,Authorization');
  res.header('Cache-Control', 'no-cache, private');
  next();
});


app.use(compression()); // <--------------------------------------------------------------


app.use(Express.static(process.env.RAZZLE_PUBLIC_DIR));
app.use(appRouting);

Dataloader is not receiving the full URL

When Dataloader component tries to fechData it passes a location.pathname which contains only the path giving away of querystring params.

  componentDidUpdate(prevProps) {
    const navigated = this.props.location !== prevProps.location;

    if (navigated) {
      const { store } = this.context; // eslint-disable-line
      fetchData(store, this.props.location.pathname); // eslint-disable-line
    }
  }

One way to solve that is by including the querystring params into url string.

  componentDidUpdate(prevProps) {
    const navigated = this.props.location !== prevProps.location;

    if (navigated) {
      const { store } = this.context; // eslint-disable-line
      fetchData(store, this.props.location.pathname + `/` + this.props.location.search); // eslint-disable-line
    }
  }

This is just a quick solution, the better way may be passing the entire location obj to fetchData to handle that.

non-www redirect

Implement a non-www redirect feature on the server and give an option to choose between with wwwor not.
Here an example:

...
function wwwRedirect(req, res, next) {
    if (req.headers.host.slice(0, 4) === 'www.') {
        var newHost = req.headers.host.slice(4);
        return res.redirect(301, req.protocol + '://' + newHost + req.originalUrl);
    }
    next();
};

app.use(wwwRedirect);

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.