Skip to content

send fails every other run. Β #86

Open
@snuggs

Description

Appologize for the gif. However a gif is worth 1000 words. 😎

The following code is running from snuggsi ツ:

const
  root   = 'mixins'
, mime   = /^\*\/\*$/
, filter = /^\/mixins\/(.*\.es)*$/g

, send   = require ('koa-send')


module.exports = async (context, next) => {

  const
    match = filter.test (context.path)
  , resource = './storable.es'

  , settings = [context, resource, { root }]

  , header = ['Content-Type', 'application/ecmascript']
  , response = match && await send ( ... settings )

  void (response && context.set ( ... header ))
    || await next ()

  console.log ('response', context.response, response)
}

By the way it's a little wonky to change headers AFTER send is called. (which just returns a file path anyways). Let me know where I can help. PR. etc.

Thanks in advance @tj
koa

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions