Ionic application that uses ZetaPush Celtia to create a survey and send messages to users.
npm install
Push your code on ZetaPush platform
npm run deploy
Run your code on your local platform
npm run start
.
└──
├── src
│ └── // Ionic application
├── worker
│ └── // Api implementation
└── package.json
Server side
Your server api in a plain old class defining your interface.
Example:
module.exports = class Api {
hello() {
return `Hello World from JavaScript ${Date.now()}`;
}
}
This code expose an API called hello which returns a string "Hello World from JavaScript" concatened with server timestamp.
You can use injected platform services with to following.
Dependency injection use injection-js
import { Injectable } = from '@zetapush/core';
import { Stack } = from '@zetapush/platform-legacy';
export default class Api {
constructor(private stack: Stack) {}
push(item) {
return this.stack.push({ stack: 'list', data: item });
}
list() {
return this.stack.push({ stack: 'list' });
}
}
To consume an API in your front-end application you have to create a mapped method.
Client side
const api = client.createProxyTaskService();
const message = await api.hello();