ColonelBundy / Moleculer Decorators
Licence: mit
decorators for moleculer
Stars: ✭ 47
Programming Languages
typescript
32286 projects
Projects that are alternatives of or similar to Moleculer Decorators
Typescript Rest
This is a lightweight annotation-based expressjs extension for typescript.
Stars: ✭ 458 (+874.47%)
Mutual labels: microservice, decorators
Nestcloud
A NodeJS micro-service solution, writing by Typescript language and NestJS framework.
Stars: ✭ 290 (+517.02%)
Mutual labels: microservice, decorators
Practical Clean Ddd
A simplified and effortless approach to get started with Domain-driven Design, Clean Architecture, CQRS, and Microservices patterns
Stars: ✭ 28 (-40.43%)
Mutual labels: microservice
Altair
Lightweight and Robust API Gateway written in Go
Stars: ✭ 34 (-27.66%)
Mutual labels: microservice
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-36.17%)
Mutual labels: microservice
React Apollo Decorators
Better decorators for Apollo and React
Stars: ✭ 39 (-17.02%)
Mutual labels: decorators
Redux Connect Decorator
React Redux's connect as a decorator.
Stars: ✭ 46 (-2.13%)
Mutual labels: decorators
Decko
💨 The 3 most useful ES7 decorators: bind, debounce and memoize
Stars: ✭ 1,024 (+2078.72%)
Mutual labels: decorators
Injection Js
Dependency injection library for JavaScript and TypeScript in 5.1K. It is an extraction of the Angular's ReflectiveInjector which means that it's well designed, feature complete, fast, reliable and well tested.
Stars: ✭ 962 (+1946.81%)
Mutual labels: decorators
Ember Arg Types
Runtime type checking & defaulting for glimmer component arguments powered by prop-types & decorators
Stars: ✭ 43 (-8.51%)
Mutual labels: decorators
Spring Boot Microservice Eureka Zuul Docker
Spring-Boot rest microservices using Eureka, Zuul, Docker. Monitoring with logstash, logback, elasticsearch, kibana
Stars: ✭ 45 (-4.26%)
Mutual labels: microservice
Cookiecutter Sanic Microservice
A template for rapid development of Sanic based RESTful Microservices
Stars: ✭ 32 (-31.91%)
Mutual labels: microservice
Nex
Aiming to simplify the construction of JSON API service
Stars: ✭ 35 (-25.53%)
Mutual labels: microservice
Spring Cloud Study
开源书《跟我学Spring Cloud》的配套代码。讨论QQ群:731548893
Stars: ✭ 1,036 (+2104.26%)
Mutual labels: microservice
Moleculer Decorators
Decorators for moleculer, Tested & accurate as of 0.14
Available options
constructOverride: false // True by default, This will override any properties defined in @Service if defined in the constructor as well.
skipHandler: true // false by default, this will let a mixin override the handler in an action. (action options)
These are defined in @Service
Example usage
const moleculer = require('moleculer');
const { Service, Action, Event, Method } = require('moleculer-decorators');
const web = require('moleculer-web');
const broker = new moleculer.ServiceBroker({
logger: console,
logLevel: "debug",
});
@Service({
mixins: [web],
settings: {
port: 3000,
routes: [
...
]
}
})
class ServiceName extends moleculer.Service {
// Optional constructor
constructor() {
this.settings = { // Overrides above by default, to prevent this, add "constructOverride: false" to @Service
port: 3001
}
}
// Without constructor (typescript)
settings = {
port: 3001
}
@Action()
Login(ctx) {
...
}
@Action({
skipHandler: true // Any options will be merged with the mixin's action.
})
Login3() { // this function will never be called since a mixin will override it, unless you specify skipHandler: false.
}
// With options
// No need for "handler:{}" here
@Action({
cache: false,
params: {
a: "number",
b: "number"
}
})
Login2(ctx) {
...
}
@Event({
group: 'group_name'
})
'event.name'(payload, sender, eventName) {
...
}
@Event()
'event.name'(payload, sender, eventName) {
...
}
@Method
authorize(ctx, route, req, res) {
...
}
started() { // Reserved for moleculer, fired when started
...
}
created() { // Reserved for moleculer, fired when created
...
}
stopped() { // Reserved for moleculer, fired when stopped
...
}
}
broker.createService(ServiceName);
broker.start();
Usage with moleculer-runner
Simply export the service instead of starting a broker manually.
It must be a commonjs module.
module.exports = ServiceName
Usage with custom ServiceFactory class
Moleculer allows you to define your own ServiceFactory class, from which your services should inherit. All you have to do, is pass your custom ServiceFactory to broker options and also extend your services from this class
const moleculer = require('moleculer');
const { Service, Action } = require('moleculer-decorators');
// create new service factory, inheriting from moleculer native Service
class CustomService extends moleculer.Service {
constructor(broker, schema) {
super(broker, schema)
}
foo() {
return 'bar';
}
}
// pass your custom service factory to broker options
const broker = new moleculer.ServiceBroker({
ServiceFactory: CustomService
});
@Service()
class ServiceName extends CustomService { // extend your service from your custom service factory
@Action()
Bar(ctx) {
return this.foo();
}
}
broker.createService(CustomService);
broker.start();
License
Moleculer Decorators is available under the MIT license.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].