Skip to content

Commit 0d3603c

Browse files
Angelo ManganielloAngelo Manganiello
authored andcommitted
added initial example cordova server
1 parent b88d0ba commit 0d3603c

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ May 30,2018 | **Release 1.0** | available from [GitHub](https://github.com/aman
4444

4545
## NEXT DEVELOPMENTS (checked in progress)
4646

47+
- [ ] Resolve api url for electron-client and in general for file protocol. Solution is in build time [adding angular env variables](https://alligator.io/angular/environment-variables/)
4748
- [ ] Create api server in cordova with [cordova plugin webserver](https://github.com/bykof/cordova-plugin-webserver) and [lockijs db](https://github.com/techfort/LokiJS)
4849
- [ ] Create ui tests with [java cucumber](https://examples.javacodegeeks.com/core-java/junit/junit-cucumber-example/)
4950
- [ ] Create api and ui tests in node app with a e2e framework
50-
- [ ] use automatic swagger-ui in node [swagger-ui-node](https://blog.cloudboost.io/adding-swagger-to-existing-node-js-project-92a6624b855b)
51+
- [ ] Use automatic swagger-ui in node [swagger-ui-node](https://blog.cloudboost.io/adding-swagger-to-existing-node-js-project-92a6624b855b)
5152

5253
## Table of contents
5354

@@ -316,6 +317,10 @@ App in electron:
316317

317318
In this way **only your frontend**, is running in the electron container and you can use the **electron-debug utility**.
318319

320+
**:warning:**
321+
> In this mode the api calls don't work without a server part is missing. Besides the backend endpoint is a file protocol instead http.
322+
323+
319324

320325
#### Electron package mode for frontend
321326

@@ -330,6 +335,9 @@ After this, you will have a single **electron-app-client 1.0.0** (for windows wi
330335
**The file created is a standalone distributable desktop app that not require Node or JRE on your machine to be executed.**
331336
In this way, **only your frontend**, is run in the electron container as a package and you can use the **electron-debug utility**.
332337

338+
**:warning:**
339+
> In this mode the api calls don't work without a server part is missing. Besides the backend endpoint is a file protocol instead http.
340+
333341

334342
#### Electron with express
335343

cordova-app/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ cordova cli 8.0.0
22

33
I have run:
44
- cordova create app com.amanganiello30.angular angularDashFullStack
5-
- cordova platform add android --> 7.0.0
5+
- cordova platform add android --> 7.0.0
6+
- cordova plugin add https://github.com/bykof/cordova-plugin-webserver
7+
- cordova plugin add cordova-sqlite-storage

cordova-app/server-cordova.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
< head >
2+
< script >
3+
4+
// Wait for device API libraries to load
5+
document.addEventListener("deviceready", onDeviceReady, false);
6+
// device APIs are available
7+
function onDeviceReady() {
8+
webserver.onRequest(
9+
function (request) {
10+
console.log("This is the request: ", request);
11+
12+
webserver.sendResponse(
13+
request.responseId, {
14+
status: 200,
15+
body: '<html>Hello World</html>',
16+
headers: {
17+
'Content-Type': 'text/html'
18+
}
19+
});
20+
});
21+
22+
// Starts webserver with default port 8080
23+
webserver.start();
24+
25+
//... after a long long time
26+
// stop the server
27+
webserver.stop();
28+
}
29+
< / script >
30+
< / head >

0 commit comments

Comments
 (0)