Web service runtime for tessellate services.
import { TessellateServer } from 'tessellate-server'
name: string
Optional application name (see koa.app.name)
Add koa Middleware that runs before any routes are handled. If defer
is set to true
, the middleware will run after all routes. Also see koa.app.use.
Start the koa application server and prometheus metrics server on the specified ports. The default value for metricsPort
is port + 1
.
koa-rx-router instance. Use it to add routes.
Stop all koa servers.
import { nconf } from 'tessellate-server'
Wrapper around nconf with default values and convenience methods.
set(key: string, value: any)
- see nconfget(key: string)
- see nconfgetObject(key: string): Object
- seeget
getString(key: string): string
- seeget
argv(args: Object)
- see nconfdefaults(defaults: Object)
- see nconf
import { Problem } from 'tessellate-server'
A throwable Error class modeled after Zalando Problem.
Run npm start
or check out the code below:
import { TessellateServer, Problem } from '../src'
import { Observable } from 'rxjs'
const server = new TessellateServer()
server.use((ctx, next) => {
console.log('Hi, this is middleware.')
return next()
})
server.router.get('/', o => o.mapTo('Hello!'))
server.router.get('/error', o => o.switchMapTo(Observable.throw(
new Problem({
title: 'Teapot',
detail: 'I am a teapot.',
status: 418
}))
))
server.start(3001)