{"id":15061626,"url":"https://github.com/apache/cordova-serve","last_synced_at":"2025-04-13T02:04:42.655Z","repository":{"id":13786535,"uuid":"74950512","full_name":"apache/cordova-serve","owner":"apache","description":"Apache Cordova Serve Library","archived":false,"fork":false,"pushed_at":"2024-12-06T00:32:00.000Z","size":503,"stargazers_count":21,"open_issues_count":9,"forks_count":31,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-03T04:16:52.661Z","etag":null,"topics":["cordova","hacktoberfest","javascript","mobile","nodejs"],"latest_commit_sha":null,"homepage":"https://cordova.apache.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-28T08:00:09.000Z","updated_at":"2024-10-23T04:56:42.000Z","dependencies_parsed_at":"2024-01-23T17:31:57.947Z","dependency_job_id":"258be3e2-5f0c-4436-bc32-f31aacfc57ae","html_url":"https://github.com/apache/cordova-serve","commit_stats":{"total_commits":91,"total_committers":20,"mean_commits":4.55,"dds":0.7692307692307692,"last_synced_commit":"9dce9f1212c3f7f8c8ee22527825940e2e1acbd1"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-serve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-serve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-serve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcordova-serve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/cordova-serve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415966,"owners_count":20935388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cordova","hacktoberfest","javascript","mobile","nodejs"],"created_at":"2024-09-24T23:22:54.955Z","updated_at":"2025-04-06T00:06:28.921Z","avatar_url":"https://github.com/apache.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#  KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n#\n--\u003e\n\n# cordova-serve\n\n[![NPM](https://nodei.co/npm/cordova-serve.png)](https://nodei.co/npm/cordova-serve/)\n\n[![Node CI](https://github.com/apache/cordova-serve/workflows/Node%20CI/badge.svg?branch=master)](https://github.com/apache/cordova-serve/actions?query=branch%3Amaster)\n\nThis module provides a JavaScript API to serve up a Cordova application in the browser.\n\n**API Example:**\n\n```js\nconst cordovaServe = require('cordova-serve')();\n\ncordovaServe.launchServer(options);\ncordovaServe.servePlatform(platform, options);\ncordovaServe.launchBrowser(options);\n```\n\n## API Methods\n\n### `launchServer()`\n\nLaunches a local HTTP server.\n\n**Code Example:**\n\n```js\nconst cordovaServe = require('cordova-serve')();\n\ncordovaServe.launchServer(options).then(function () {\n    const { server, port, root } = cordovaServe;\n    ...\n}, error =\u003e {\n    console.log(`An error occurred: ${error}`);\n});\n```\n\n**Parameters:**\n\n* **options**: described below in the following section \"**launchServer \u0026 servePlatform Options**\".\n\n**Return:**\n\nReturns a resolved or rejected promise depending on if the server had launched successfully.\n\nOn a fulfilled promise, the following properties are available on the returned object:\n\nProperty | Description\n-|-\n`serve` | The Node `http.Server` instance.\n`root` | The `root` that was specified, or `cwd` if none specified.\n`port` | The port that was used. (Either the requested port, the default port of `8000`, or the incremented value of the chosen port when the chosen port is already in use).\n\n## `servePlatform()`\n\nLaunches a server that serves up any Cordova platform (e.g. `browser`, `android`, etc) from the current project.\n\n**Code Example:**\n\n```js\nconst cordovaServe = require('cordova-serve')();\n\ncordovaServe.servePlatform(platform, options).then(() =\u003e {\n    const { server, port, projectRoot, root } = cordovaServe;\n    ...\n}, error =\u003e {\n    console.log(`An error occurred: ${error}`);\n});\n```\n\n**Parameters:**\n\n* **options**: described below in the following section \"**launchServer \u0026 servePlatform Options**\".\n\n**Return:**\n\nNote that for `servePlatform()`, the `root` value should be a Cordova project's root folder or any folder within it. `servePlatform()` will replace it with the platform's `www_dir` folder. If this value is not specified, the *cwd* will be used.\n\nReturns a resolved or rejected promise depending on if the server had launched successfully.\n\nOn a fulfilled promise, the following properties are available on the returned object:\n\nProperty | Description\n-|-\n`serve` | The Node `http.Server` instance.\n`root` | The requested platform's `www` folder.\n`projectRoot` | The root folder of the Cordova project.\n`port` | The used port. requested port, the default port `8000`, or incremented value of the chosen port when already in use).\n\n### `launchBrowser()`\n\nLaunches a browser window pointing to the specified URL.\n\n**Code Example:**\n\n```js\nconst cordovaServe = require('cordova-serve')();\n\ncordovaServe.launchBrowser(options).then(\n  stdout =\u003e {\n    console.log(`Browser was launched successfully: ${stdout}`);\n  },\n  error =\u003e {\n    console.log(`An error occurred: ${error}`);\n  }\n);\n```\n\n**Parameters:**\n\n* **options** (optional):\n\nOptions | Description\n-|-\n`url` | The URL to open in the browser.\n`target` | The browser identifier to launch. **Valid identifier**: `chrome`, `chromium`, `firefox`, `ie`, `opera`, `safari`. (**Default:** `chrome`.)\n\n**Return:**\n\nReturns a resolved or rejected promise depending on if the browser had launched successfully.\n\n## launchServer \u0026 servePlatform Options\n\nThe `options` object passed to `launchServer()` and `servePlatform()` supports the following values (all optional):\n\nOptions | Description\n-|-\n`root` | The file path on the local file system that is used as the root for the server, for default mapping of URL path to the local file system path.\n`port` | The port for the server. Note that if this port is already in use, it will be incremented until a free port is found.\n`router` | An `ExpressJS` router. If provided, this will be attached *before* default static handling.\n`noLogOutput` | If true, all log output will be turned off.\n`noServerInfo` | If `true`, the `Static file server running on...` message will not be outputed.\n`events` | An `EventEmitter` to use for logging. If provided, logging will be output using `events.emit('log', msg)`. If not provided, `console.log()` will be used. Note that nothing will be output in either case if `noLogOutput` is `true`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-serve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcordova-serve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcordova-serve/lists"}