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:
Lihang Xu 2022-10-09 22:48:59 +08:00 committed by GitHub
parent 98dc7c4be0
commit f8c6430a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 0 deletions

View File

@ -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
View 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

View 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

View 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;
}
}