Skip to content

Commit

Permalink
feat: add options for koa middleware server-index and static
Browse files Browse the repository at this point in the history
  • Loading branch information
soda-x committed Jun 20, 2016
1 parent 6535b53 commit 5938f85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const defaultCwd = process.cwd();
const defaultArgs = {
port: '8000',
cwd: defaultCwd,
enabledMiddlewareServeIndex: true,
enabledMiddlewareStatic: true,
resolveDir: [defaultCwd],
};
const data = {};
Expand All @@ -24,10 +26,12 @@ export default function createServer(_args, callback) {
context.get = key => data[key];
context.set('__server_listen_log', true);

pluginNames = pluginNames.concat([
join(__dirname, './plugins/static'),
join(__dirname, './plugins/serve-index'),
]);
if (args.enabledMiddlewareStatic) {
pluginNames.push(join(__dirname, './plugins/static'));
}
if (args.enabledMiddlewareServeIndex) {
pluginNames.push(join(__dirname, './plugins/serve-index'));
}

const plugins = resolvePlugins(pluginNames, resolveDir, cwd);
function _applyPlugins(name, pluginArgs, _callback) {
Expand Down

0 comments on commit 5938f85

Please sign in to comment.