
Security News
Federal Audit Finds NIST Wasted Funds With No Plan to Clear NVD Backlog
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.
methodulus
Advanced tools
npm i -S methodulus
This example creats a rest (express based) server using a controller class
Playerit is configured to run the class code locally via an http server.
import { Player } from './controllers/player';
import { ServerConfig, ClientConfig, ConfiguredServer, MethodType, ServerType } from 'methodulus';
@ServerConfig(ServerType.Express, { port: process.env.PORT || 8020 })
@ClientConfig(Player, MethodType.Local)
class SetupServer extends ConfiguredServer {
}
new SetupServer();
import { Body, Method, MethodConfig, MethodType, Param, Query, Verbs, MethodError, MethodResult } from 'methodulus';
import { PlayerModel } from '../models/player';
@MethodConfig('Player')
export class Player {
@Method(Verbs.Post, '/api/player')
public async create() {
let p = new PlayerModel('1', 'player 1');
await DB.Player.insert(p);
return new MethodResult(p)
}
@Method(Verbs.Get, '/api/player/:player_id')
public async read( @Param('player_id') playerId: number) {
return await DB.Player.find({ 'Id': playerId });
}
@Method(Verbs.Put, '/api/player')
public async update() {
}
@Method(Verbs.Delete, '/api/player')
public delete() {
}
}
this class is the base class for the server implementation. it uses the Server & Client decorators to apply the desired configuration.
syntetic suger for MethodulusConfig.run() function.
syntetic suger for MethodulusConfig.use() function.
configuration must complete before the server starts. configure each controller class to its desired state
let config = new MethodulusConfig()
the run method determines what kind of server to run on the listening part of the application. to listen to REST request you should run ServerType.Expess and to listen to redis channel use ServerType.Redis .
ExpressRedisMQSocketthe use method registers the way a class should be activated. the first parameter is a class decorated with methodulus decoratos.
avaliable options are
Local | Http | MQ | Socket | Redis
Local
run the code in the class, no proxy or transport required.
Http
run the code using an http request to a microservice.
MQ
use amqp rpc to execute the class code
Socket
directly connect to a server using websocket connection.
Redis
use redis rpc to execute the class code
in order to access the correct service methodulus uses a resolver, which may be a literal containing the service uri or a promise returning the same.
resolvers are attached to a class, allowing the application to use different resolvers for different services.
an instamce of methodulus can run multiple listeners in different channels. the current list is:
expresssocketioamqpredishere is a simple local configuration: The class
Playerwill execute locally.
let servers = ['express'];
let config = new MethodulusConfig(servers);
let resolver = 'http://127.0.0.1:8090';
config.run(ServerType.express, {port: process.env.PORT })
config.use(TestClass, MethodType.Local,resolver);
creates an agnostic configured server.
const server = new Server(process.env.PORT);
Server methods are chainable and should e called in this order
const server = await new Server(process.env.PORT).configure(config).start();
decorating a class with the decorator will turn it into a methodulus end point.
@MethodulusConfig(applicationname, [middlewares]?)
Each decorated method in the MethodConfig decorated class will become a function endpoint of the methodulus application.
@Method(Verb, route, [middlewares])
a decorated method should use the following parameter decorators to indicate the source of each argument.
FAQs
Unknown package
We found that methodulus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.