We are excited to announce the release of Expressive Tea 1.3 Beta! This release includes many significant new features, microservices, and performance improvements and not breaking changes.
This version will be retro-compatible with the current production version 1.2.x and will allow you to move on to the beta version without any issue; however, as this is a beta version, some changes will still apply and could break your current projects in the future, please be aware.
npm install --save @zerooneit/expressive-tea@next
yarn add @zerooneit/expressive-tea@next
Starting from this version and so on, Expressive Tea supports microservices; this will be possible by introducing two new decorators @Teapot and @Teacup. Expressive Tea takes simplicity so seriously that you will need to set up your configurations per every Teacup (microservices client), and Teapot (microservices host) will take care of everything for you, it will verify that every Teacup belongs to the implementation of the microservices network by providing an encrypted handshake and verification by using a private and public key.
Once you configure your servers with the decorators mentioned (will explain in detail below), the primary server or “Teapot” will validate, register, and auto-setting the microservice net even in runtime.
A Teapot is an entity that allows an Expressive Tea’s projects converts automatically in a microservice gateway for one or more other Expressive Tea projects configured as Teacup. You can do this by adding the decorator @Teapot into the Bootstrap class; the only parameters required to set up are serverKey and clientKey needed to secure and register Teacups, settings example on the code down below.
@Pour(ExpressPlugin)
@Static('./public')
@ServerSettings({
port: 8084,
})
@Teapot({
serverKey: '3xcJXjgNwe6yNxkx7F0/QzPmEgu7WkLBUrPwB2+G8/4=',
clientKey: '2piAM0vUyIGZMJZpW1TIC7/hpX3gYwufTv11kpVviyE='
})
class Bootstrap extends Boot {
@RegisterModule(RootModule)
async start(): Promise<ExpressiveTeaApplication> {
return super.start();
}
}
A Teacup is an entity that allows Expressive Tea projects to be used as microservice clients and receive a request from Teapot gateway. Registration and validations will be taken care of by gateway; if the client key is not assigned, it will not register. Once registered after assurances, it will receive a request from Teapot Gateway when the user points to the endpoint registered by Teacup. However, if a Teacup is part of a group of Expressive Tea instances on the same endpoint, it will defer the request to the Round Robin on the Teapot side. To set up, a Teacup @Teacup decorator needs to be used in the bootstrap class and will require four settings.
@Teacup({
clientKey: '2piAM0vUyIGZMJZpW1TIC7/hpX3gYwufTv11kpVviyE=',
serverUrl: `teapot://example-teapot.com/teapot`,
address: 'http://example-teacup.com',
mountTo: '/teacup-1'
})
class Bootstrap extends Boot {
@RegisterModule(TeacupModule)
async start(): Promise<ExpressiveTeaApplication> {
return super.start();
}
}
Tea CLI is on development, yet the command presented here should change by the time being, make sure to follow the documentation and update constantly.
Tea CLI received another upgrade to allow the server key and client key to add them to the Teapot and Teacup configuration to use it install and use.
npm install -g @expressive-tea/tea
npm update -g @expressive-tea/tea
To use you can use the below example:
~
❯ tea teapod-secret
Welcome to TEA a CLI tool for Expressive Tea applications.
;,'
_o_ ;:;'
,-.'---`.__ ;
((j`=====',-'
`-\ /
`-=-'
Generating Teapod and Teacup Key.
Server Key : faB8yp7h1VpFJg3YLeFprzPqYrkc
Clients Key: ScqtXNhsRFNNr8S8AwBz+rDAtcZL
Salt: 23cfdfc02be222691c1c217b323e1dd332387e9df9
CAUTION:
All keys generated here are unique, please store them in a secure place and avoid to make it public..
Under Module declaration, the “providers” property are mandatory, even if you are not used. On this version, we flag the “providers” property to be optional, so instead to declare the module as:
@Module({
controllers: [RootController],
providers: [],
mountpoint: '/'
})
export default class RootModule {
}
now you can declared as:
@Module({
controllers: [RootController],
mountpoint: '/'
})
export default class RootModule {
}
We work on this version to provide Types and Interfaces to the developers that want to contribute to our project; this means we made some internal refactoring to increase code readability, types check and interfaces implementation to avoid errors when coding, so in this case, if there is someone new in the project will be understood quickly.
We updated our base dependencies to the last compatible version to the current code to avoid errors and security breaches and give the users peace of mind; these recommendations come from Snyk and dependabot in Github.
We made a refactoring to start to remove some complex functions inside of the project; we introduce Engines to many different aspects of Expressive Tea, there is, for example, an Engine for HTTP(S) related code and other different Engine for Websocket, with this our developers will be aware where need to modify and also allow to move complexity away from main components.
Internally, an Inversify Container includes using Dependency Injections so engines can get the data they need by injecting values directly in the Engine Constructors. Also, the method start from Boot Class has been reduced drastically by using dependency injection and engines.
expresive-tea (this link opens in a new window) by Expressive-Tea (this link opens in a new window)
A Express and Typescript REST Service Template.
4 Subscribers 47 Watchers 8 Forks Check out this repository on GitHub.com (this link opens in a new window)
Lead Developer for Expressive Tea - Javascript Fullstack Developer - Open Source Advocate - Amateur Data Science - Python Enthusiastic
Diego Resendez