Polka: How fast compare to fastify?

Created on 10 Jan 2019  Â·  4Comments  Â·  Source: lukeed/polka

Most helpful comment

It's included in the benchmarks on the main readme: https://github.com/lukeed/polka/blob/master/readme.md#benchmarks

That said, I've heard fastify has gotten a bit faster in recent version(s). If that's the case, I can't speak to it.

However, the upcoming 1.0 for Polka (TBA this month) is significantly faster than the current version of Polka, too. 🎊

All 4 comments

It's included in the benchmarks on the main readme: https://github.com/lukeed/polka/blob/master/readme.md#benchmarks

That said, I've heard fastify has gotten a bit faster in recent version(s). If that's the case, I can't speak to it.

However, the upcoming 1.0 for Polka (TBA this month) is significantly faster than the current version of Polka, too. 🎊

Please make polka easier for auth, ejs and graphql.

I could make an ejs package, but it's fairly easy:

const ejs = require('ejs');
const flru = require('flru');
const { join } = require('path');

const views = join(__dirname, '../views');

ejs.cache = flru(100); // LRU cache with 100-item limit

polka()
  .use((req, res, next) => {
    res.render = (tmpl, data) => {
      res.setHeader('content-type', 'text/html');
      res.end( ejs.render(tmpl, data) );
    };
    res.renderFile = (file, data) => {
      let tmpl = fs.readFileSync(join(views, file));
      return res.render(tmpl, data);
    };
    next();
  })
  .get('/users/:username', async (req, res) => {
    let { username } = req.params;
    let data = await GET(`https://..../users/${username}`);
    res.renderFile('users/profile', data);
  });

Auth is completely dependent on your application, but any existing library will work with Polka. The most popular option is probably passport – which is compatible, but I don't like/use it so I can't offer guidance there.

Same story with GraphQL – just have to integrate/properly mount existing middleware packages.

thanks lukeed, i wish i can help you if i can to make it stable and fast.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ansarizafar picture ansarizafar  Â·  3Comments

dasantonym picture dasantonym  Â·  4Comments

paz-raon picture paz-raon  Â·  10Comments

benderTheCrime picture benderTheCrime  Â·  11Comments

flawyte picture flawyte  Â·  7Comments