Skip to content

A basic application that allows you to use a Avengers character and chat with others.

Notifications You must be signed in to change notification settings

zetapush-demo/avengers-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

avengers-chat

A basic application that allows you to use a Avengers character and chat with others.

Tutorial

You're new with ZetaPush ? Read this tutorial or try it on Katacoda!

Installation

npm install

Deployment

Push your code on ZetaPush platform

npm run deploy

Development

Run your code on your local platform

npm run start

Project structure

.
└──
  ├── front
  │  ├── index.html
  │  └── index.js
  ├── worker
  │  └── index.ts (api implementation)
  └── package.json

How it works?

Server side

Your server api in a plain old class defining your interface.

Example:

export default class Api {
  hello() {
    return `Hello World from Worker ${Date.now()}`;
  }
}

This code expose an API called hello which returns a string "Hello World from Worker" concatened with server timestamp.

You can use injected platform services with to following.

Dependency injection use injection-js

const { Injectable } = require('@zetapush/core');
const { Stack } = require('@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.list({ stack: 'list' });
  }
}

To consume an API in your front-end application you have to create a mapped method.

Client side

Register your API mapping class

const api = client.createProxyTaskService();

Invoke your remote API method

const message = await api.hello();

About

A basic application that allows you to use a Avengers character and chat with others.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published