1 |
|
2 | 'use strict'
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const path = require('path')
|
12 |
|
13 | const chalk = require('chalk')
|
14 |
|
15 | const readCors = require('../lib/cors/read.js')
|
16 | const serve = require('../lib/serve.js')
|
17 |
|
18 | module.exports = function (
|
19 | input /* : Array<string> */,
|
20 | flags /* : CLIFlags */,
|
21 | logger /* : typeof console */,
|
22 | options /* : CLIOptions */
|
23 | ) /* : Promise<void> */ {
|
24 | const cwd = path.resolve(flags.cwd)
|
25 | const example = path.join('helloworld', 'index.js')
|
26 | return readCors(cwd)
|
27 | .then((cors) => serve.startServer(logger, {
|
28 | cors,
|
29 | cwd,
|
30 | port: flags.port || 3000
|
31 | })
|
32 | .then((server) => logger.log(`
|
33 | HTTP service for local development is available from:
|
34 | http://localhost:${server.info.port}
|
35 |
|
36 | Your current directory "." is:
|
37 | ${cwd}
|
38 |
|
39 | HTTP API files should be in sub-folders within the directory above E.g:
|
40 | ${example} -> ${server.info.uri}/helloworld
|
41 |
|
42 | Create new HTTP APIs, rename, update, or delete them at any time.
|
43 | Your changes automatically take effect on the next request
|
44 |
|
45 | ${chalk.yellow('Hit CTRL-C to stop the service')}
|
46 | `)))
|
47 | }
|