mirror of
https://github.com/appium/appium.git
synced 2026-02-22 03:08:47 -06:00
appium-express
Express server tuned for to serve Appium.
Configuration
The appium-express server comes configured with:
- appropriate logging formats
- service of necessary static assets
- allowance of cross-domain requests
- default error handling
- 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');
});
}
const port = 5000;
const host = 'localhost';
const appiumServer = await server({
routeConfiguringFunction,
port,
host,
});
Watch
npm run watch
Test
npm test