-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 69 additions & 0 deletions
69
src/@awesome-cordova-plugins/plugins/gcdwebserver/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |