Serve: Programmatic API

Created on 24 Jan 2017  路  5Comments  路  Source: vercel/serve

For loading serve inside an app

help wanted minor

All 5 comments

That would be really cool 馃憤

Hi everyone. I want to work on this.

Going through the code, I see that when using the CLI, we determine the args and the directory by line 43 in bin/serve.js.

A high-level solution, I think, would be to extract the rest of the file into a function that accepts flags and directory as arguments. We could then just export that function as the API.

What are your thoughts on this?

@dar5hak Great idea! Maybe we can even keep the CLI like it is and just let the programmatic API run the CLI as a command using child_process.spawn or child_process.exec + setting the flags by setting process.argv. 馃

@leo Oh yes! That would be simpler. I'll send a pull request tonight (UTC+0530).

Would you prefer an index.js at the project root, or inside lib/?

@dar5hak A file named api.js inside lib/... 馃槉

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nermin99 picture nermin99  路  3Comments

Simran-B picture Simran-B  路  4Comments

lightzane picture lightzane  路  5Comments

Olexiy665 picture Olexiy665  路  3Comments

malinda1986 picture malinda1986  路  6Comments