Polka: Feature request: add .static() method

Created on 22 Jan 2018  路  3Comments  路  Source: lukeed/polka

Express provided a nifty helper for defining a static folder for binary assets, such as styles, images, fonts, etc.

Would be great to have a similar feature, unless this was explicitly left out in order for folks to derive their own.

Most helpful comment

Yeah, definitely! If the timeline allows it, I want 1.0 to release with a full documentation website too to get people away from a mile-long README.

All 3 comments

Hi there! This is intentionally left out. All Express does is expose the serve-static dependency (source) — it's only included to maintain the legacy API.

You can already use serve-static with Polka, since it's only a middleware! There's an example, too!

Admittedly, the current usage is a little funky for Express users. A refactor is in the works right now that will change this & make it more familiar for Express veterans:

const serve = require('serve-static')('assets', { ... });

polka()
  .use(serve)
  .get('...', () => {})

Closing since I definitely don't want to include this in core. But, a lighter serve-static alternative may be on the agenda... I haven't committed one way or another yet 馃槅

Good deal, I like that approach, but a getting started guide for express users might be a cool documentation feature.

Yeah, definitely! If the timeline allows it, I want 1.0 to release with a full documentation website too to get people away from a mile-long README.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ansarizafar picture ansarizafar  路  3Comments

deadcoder0904 picture deadcoder0904  路  8Comments

dasantonym picture dasantonym  路  4Comments

alekbarszczewski picture alekbarszczewski  路  3Comments

galuh1300d picture galuh1300d  路  4Comments