Files
appium/lib/express
Jonathan Lipps f66dadcd6b make allowing CORS conditional (#285)
* make allowing CORS conditional
It turns out blindly allowing CORS could be a security hazard (who knew)
See https://github.com/w3c/webdriver/pull/1362 for the conversation that led to this realization.
This change makes the cross domain middleware conditional (defaulting to the current behavior).
This way Appium can pass in 'false' based on a flag, for better server security.

* actually include function parameter we can use from appium
2018-11-21 16:46:53 -08:00
..
2018-01-29 12:41:14 -08:00
2016-05-05 17:25:08 -07:00
2018-10-03 09:00:58 -04:00
2018-10-03 09:00:58 -04:00

appium-express

Express server tuned for to serve Appium.

Configuration

The appium-express server comes configured with:

  1. appropriate logging formats
  2. service of necessary static assets
  3. allowance of cross-domain requests
  4. default error handling
  5. fix for invalid content types sent by certain clients

To configure routes, a function that takes an Express server is passed into the server. This function can add whatever routes are wanted.

Usage

import { server } from 'appium-base-driver';


// configure the routes
function configureRoutes (app) {
  app.get('/hello', (req, res) => {
    res.header['content-type'] = 'text/html';
    res.status(200).send('Hello');
  });
  app.get('/world', (req, res) => {
    res.header['content-type'] = 'text/html';
    res.status(200).send('World');
  });
}

let port = 5000;
let host = 'localhost';

let appiumServer = await server(configureRoutes, port, host);

Watch

npm run watch

Test

npm test