![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
cordova-serve
Advanced tools
Apache Cordova server support for cordova-lib and cordova-browser.
This module provides a JavaScript API to serve up a Cordova application in the browser.
API Example:
const cordovaServe = require('cordova-serve')();
cordovaServe.launchServer(options);
cordovaServe.servePlatform(platform, options);
cordovaServe.launchBrowser(options);
launchServer()
Launches a local HTTP server.
Code Example:
const cordovaServe = require('cordova-serve')();
cordovaServe.launchServer(options).then(function () {
const { server, port, root } = cordovaServe;
...
}, error => {
console.log(`An error occurred: ${error}`);
});
Parameters:
Return:
Returns a resolved or rejected promise depending on if the server had launched successfully.
On a fulfilled promise, the following properties are available on the returned object:
Property | Description |
---|---|
serve | The Node http.Server instance. |
root | The root that was specified, or cwd if none specified. |
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). |
servePlatform()
Launches a server that serves up any Cordova platform (e.g. browser
, android
, etc) from the current project.
Code Example:
const cordovaServe = require('cordova-serve')();
cordovaServe.servePlatform(platform, options).then(() => {
const { server, port, projectRoot, root } = cordovaServe;
...
}, error => {
console.log(`An error occurred: ${error}`);
});
Parameters:
Return:
Note 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.
Returns a resolved or rejected promise depending on if the server had launched successfully.
On a fulfilled promise, the following properties are available on the returned object:
Property | Description |
---|---|
serve | The Node http.Server instance. |
root | The requested platform's www folder. |
projectRoot | The root folder of the Cordova project. |
port | The used port. requested port, the default port 8000 , or incremented value of the chosen port when already in use). |
launchBrowser()
Launches a browser window pointing to the specified URL.
Code Example:
const cordovaServe = require('cordova-serve')();
cordovaServe.launchBrowser(options).then(
stdout => {
console.log(`Browser was launched successfully: ${stdout}`);
},
error => {
console.log(`An error occurred: ${error}`);
}
);
Parameters:
Options | Description |
---|---|
url | The URL to open in the browser. |
target | The browser identifier to launch. Valid identifier: chrome , chromium , firefox , ie , opera , safari . (Default: chrome .) |
Return:
Returns a resolved or rejected promise depending on if the browser had launched successfully.
The options
object passed to launchServer()
and servePlatform()
supports the following values (all optional):
Options | Description |
---|---|
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. |
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. |
router | An ExpressJS router. If provided, this will be attached before default static handling. |
noLogOutput | If true, all log output will be turned off. |
noServerInfo | If true , the Static file server running on... message will not be outputed. |
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 . |
FAQs
Apache Cordova server support for cordova-lib and cordova-browser.
The npm package cordova-serve receives a total of 17,987 weekly downloads. As such, cordova-serve popularity was classified as popular.
We found that cordova-serve demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.