This repository has been archived by the owner on May 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
215 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
//@flow | ||
/* eslint-env node */ | ||
const envVarsPlugin = require('./environment-variables-plugin'); | ||
const getEnv = require('./environment-variables-plugin'); | ||
const {createPlugin} = require('fusion-core'); | ||
|
||
const path = require('path'); | ||
const mount = require('koa-mount'); | ||
const serve = require('koa-static'); | ||
|
||
module.exports = function(dir /* : string */) { | ||
const {assetPath, env} = envVarsPlugin().of(); | ||
// setting defer here tells the `serve` middleware to `await next` first before | ||
// setting the response. This allows composition with user middleware | ||
return mount( | ||
assetPath, | ||
serve(path.resolve(dir, `.fusion/dist/${env}/client`), {defer: true}) | ||
); | ||
return createPlugin({ | ||
middleware: () => { | ||
const {assetPath, env} = getEnv(); | ||
// setting defer here tells the `serve` middleware to `await next` first before | ||
// setting the response. This allows composition with user middleware | ||
return mount( | ||
assetPath, | ||
serve(path.resolve(dir, `.fusion/dist/${env}/client`), {defer: true}) | ||
); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
/* eslint-env node */ | ||
|
||
const renderError = require('../build/server-error').renderError; | ||
const {createPlugin} = require('fusion-core'); | ||
|
||
module.exports = function() { | ||
return async function middleware(ctx, next) { | ||
try { | ||
await next(); | ||
} catch (err) { | ||
ctx.status = err.statusCode || err.status || 500; | ||
ctx.body = renderError(err); | ||
} | ||
}; | ||
}; | ||
module.exports = createPlugin({ | ||
middleware: () => | ||
async function middleware(ctx, next) { | ||
try { | ||
await next(); | ||
} catch (err) { | ||
ctx.status = err.statusCode || err.status || 500; | ||
ctx.body = renderError(err); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
console.log('helloworld'); | ||
import App from 'fusion-core'; | ||
|
||
export default async function() { | ||
return { | ||
plugins: [], | ||
callback() {}, | ||
}; | ||
return new App('el', el => el); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
export default function() { | ||
return { | ||
plugins: [], | ||
callback() { | ||
console.log(`main __BROWSER__ is ${__BROWSER__}`); | ||
console.log(`main __DEV__ is ${__DEV__}`); | ||
console.log(`main __NODE__ is ${__NODE__}`); | ||
}, | ||
}; | ||
import App from 'fusion-core'; | ||
|
||
export default async function() { | ||
console.log(`main __BROWSER__ is ${__BROWSER__}`); | ||
console.log(`main __DEV__ is ${__DEV__}`); | ||
console.log(`main __NODE__ is ${__NODE__}`); | ||
return new App('el', el => el); | ||
} |
Oops, something went wrong.