Skip to content

Commit

Permalink
comitting and pushing new patch version
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasak committed Dec 26, 2016
1 parent 1df2866 commit 485e402
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions build/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,17 @@ const patch = route('patch');

// static file serving async-middleware
const serve = (folder = './', route = '/') => context => {
const { req, res } = context,
const { req, res, send, sendFile } = context,
{ url } = req,
filepath = `${ process.cwd() }/${ folder }/${ url.slice(1).replace(new RegExp(`/^${ route }/`, `ig`), '') }`.replace(/\/\//ig, '/');

return new Promise((y, n) => fs.stat(filepath, (err, stats) => {
if (!err && stats.isFile()) {
addMIME(url, res);
fs.createReadStream(filepath).pipe(res);
return n(context);
return fs.readFile(filepath, (err, data) => {
addMIME(url, res);
send(data.toString());
n(context);
});
}
y(context);
}));
Expand Down
10 changes: 6 additions & 4 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,18 @@ export const patch = route('patch')

// static file serving async-middleware
export const serve = (folder='./', route='/') => context => {
const {req, res} = context
const {req, res, send, sendFile} = context
, {url} = req
, filepath = `${process.cwd()}/${folder}/${url.slice(1).replace(new RegExp(`/^${route}/`,`ig`), '')}`.replace(/\/\//ig, '/')

return new Promise((y, n) =>
fs.stat(filepath, (err, stats) => {
if(!err && stats.isFile()){
addMIME(url, res)
fs.createReadStream(filepath).pipe(res)
return n(context)
return fs.readFile(filepath, (err, data) => {
addMIME(url, res)
send(data.toString())
n(context)
})
}
y(context)
}))
Expand Down

0 comments on commit 485e402

Please sign in to comment.