UNPKG

1.12 kBJavaScriptView Raw
1/* @flow */
2'use strict'
3
4/* ::
5import type {
6 CLIFlags,
7 CLIOptions
8} from '../types.js'
9*/
10
11const path = require('path')
12
13const chalk = require('chalk')
14
15const readCors = require('../lib/cors/read.js')
16const serve = require('../lib/serve.js')
17
18module.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(`
33HTTP service for local development is available from:
34 http://localhost:${server.info.port}
35
36Your current directory "." is:
37 ${cwd}
38
39HTTP API files should be in sub-folders within the directory above E.g:
40 ${example} -> ${server.info.uri}/helloworld
41
42Create new HTTP APIs, rename, update, or delete them at any time.
43Your changes automatically take effect on the next request
44
45${chalk.yellow('Hit CTRL-C to stop the service')}
46`)))
47}