Add a hypothetical Echo example

This commit is contained in:
joeduffy 2016-12-14 15:13:17 -08:00
parent 646bb624db
commit 46e89084bf
2 changed files with 49 additions and 0 deletions

26
examples/echo/echo.mu Normal file
View file

@ -0,0 +1,26 @@
// Copyright 2016 Marapongo, Inc. All rights reserved.
module echo
import mu
// Echo is a simple service that wraps an API gateway and exposes a single Say function.
service Echo {
ctor() {
new mu.APIGateway {
api = this
impl = "./mu.ts"
port = this.properties.port
}
}
interface {
// Say simply echoes back the given string.
Say(s: string): string
}
properties {
// port is an optional port number for the API service.
optional port: number = 80
}
}

23
examples/echo/echo.ts Normal file
View file

@ -0,0 +1,23 @@
// Copyright 2016 Marapongo, Inc. All rights reserved.
import * as mu from 'mu';
// Echo is a simple service that wraps an API gateway and exposes a single Say function.
class Echo extends mu.Service {
constructor(
// port is an optional port number for the API service.
port: number = 80
) {
new mu.APIGateway({
api: this
port: port
});
}
// Say simply echoes back the given string.
@mu.api()
public Say(s: string): string {
return s;
}
}