feat(GCDWebServer): add plugin (#4302)
* add GCDWebServer * fix plugin ref and add the server options interface * fix the pluginRef's case * update name * add docs
This commit is contained in:
parent
98dc7c4be0
commit
f8c6430a26
@ -216,6 +216,7 @@
|
||||
* [Printer](plugins/printer.md)
|
||||
* [Browser Tab](plugins/browser-tab.md)
|
||||
* [Dynamsoft Barcode Scanner](plugins/dynamsoft-barcode-scanner.md)
|
||||
* [GCDWebServer](plugins/gcdwebserver.md)
|
||||
* [Installation](installation.md)
|
||||
* [FAQ](faq.md)
|
||||
|
||||
|
19
docs/plugins/gcdwebserver.md
Executable file
19
docs/plugins/gcdwebserver.md
Executable file
@ -0,0 +1,19 @@
|
||||
# GCDWebServer
|
||||
|
||||
```
|
||||
$ ionic cordova plugin add cordova-plugin-gcdwebserver
|
||||
$ npm install @awesome-cordova-plugins/gcdwebserver
|
||||
```
|
||||
|
||||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/gcdwebserver/)
|
||||
|
||||
Plugin Repo: [https://github.com/xulihang/cordova-plugin-gcdwebserver](https://github.com/xulihang/cordova-plugin-gcdwebserver)
|
||||
|
||||
The [GCDWebServer](https://github.com/swisspol/GCDWebServer/) Plugin can start an HTTP server to serve static files.
|
||||
|
||||
## Supported platforms
|
||||
|
||||
iOS
|
||||
|
||||
|
||||
|
19
docs/plugins/gcdwebserver/README.md
Executable file
19
docs/plugins/gcdwebserver/README.md
Executable file
@ -0,0 +1,19 @@
|
||||
# GCDWebServer
|
||||
|
||||
```
|
||||
$ ionic cordova plugin add cordova-plugin-gcdwebserver
|
||||
$ npm install @awesome-cordova-plugins/gcdwebserver
|
||||
```
|
||||
|
||||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/gcdwebserver/)
|
||||
|
||||
Plugin Repo: [https://github.com/xulihang/cordova-plugin-gcdwebserver](https://github.com/xulihang/cordova-plugin-gcdwebserver)
|
||||
|
||||
The [GCDWebServer](https://github.com/swisspol/GCDWebServer/) Plugin can start an HTTP server to serve static files.
|
||||
|
||||
## Supported platforms
|
||||
|
||||
iOS
|
||||
|
||||
|
||||
|
69
src/@awesome-cordova-plugins/plugins/gcdwebserver/index.ts
Executable file
69
src/@awesome-cordova-plugins/plugins/gcdwebserver/index.ts
Executable file
@ -0,0 +1,69 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Plugin,
|
||||
Cordova,
|
||||
CordovaProperty,
|
||||
CordovaInstance,
|
||||
InstanceProperty,
|
||||
AwesomeCordovaNativePlugin,
|
||||
} from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface ServerOptions {
|
||||
port?: number;
|
||||
folder?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name gcdwebserver
|
||||
* @description
|
||||
* This plugin can start an HTTP server using GCDWebServer
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { GCDWebServer } from '@awesome-cordova-plugins/gcdwebserver';
|
||||
*
|
||||
*
|
||||
* constructor(private gcdwebserver: GCDWebServer) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* await this.gcdwebserver.startServer({});
|
||||
*
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'gcdwebserver',
|
||||
plugin: 'cordova-plugin-gcdwebserver',
|
||||
pluginRef: 'cordova.plugins.GCDServer',
|
||||
repo: 'https://github.com/xulihang/cordova-plugin-gcdwebserver',
|
||||
install: '',
|
||||
installVariables: [],
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class GCDWebServer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* start the server
|
||||
* @param options {ServerOptions}
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
startServer(options: ServerOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* stop the server
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
stopServer(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user