
Research
/Security News
11 Malicious Go Packages Distribute Obfuscated Remote Payloads
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
node-master-controller
Advanced tools
Master Controller with automated swagger docs creation for node express app
node-master-controller is a powerful npm package designed to help you create APIs and sockets super fast. It is a master-controller-based express package that provides a streamlined way to manage your routes and socket events. It also automates the creation of Swagger documentation for your express application
npm install node-master-controller
or
yarn add node-master-controller
import { masterController } from 'node-master-controller'
const app = express()
// routersPath: routesPath,
// generateSwaggerDocs: true,
// swaggerDocsEndpoint: '/swagger',
// swaggerDocPath,
// modifySwaggerDoc
app.use(masterController({
// make sute to use absolute path for the routes directory
routersPath: path.join(__dirname, 'routes'),
// whether to generate swagger docs or not
generateSwaggerDocs: true,
// if you want to give your swagger doc
swaggerDocPath: path.join(__dirname, 'swagger.json'),
// swagger docs endpoint
swaggerDocsEndpoint: '/api-docs',
// whether to modify your provided swagger doc or not
modifySwaggerDoc: true,
}))
app.listen(3000, () => {
console.log('Server started')
})
import { MasterController, RequestBuilder, ResponseBuilder } from 'node-master-controller'
import Joi from 'joi'
class Controller extends MasterController<IParams, IQuery, IBody> {
// swagger documetation for the api
static doc() {
return {
tags: ['User'],
summary: 'Register User',
description: 'Register User',
}
}
// add your validations here,
// rest of the swagger documentation will be generated automatically from the validation
public static validate(): RequestBuilder {
const payload = new RequestBuilder()
// request body validation
payload.addToBody(
Joi.object().keys({
name: Joi.string().required(),
lastName: Joi.string().required(),
email: Joi.string().email().required(),
password: Joi.string().min(8).max(20).required(),
}),
)
// request query validation
payload.addToQuery(
Joi.object().keys({
limit: Joi.number().required(),
offset: Joi.number().required(),
}),
)
// request params validation
payload.addToParams(
Joi.object().keys({
id: Joi.number().required(),
}),
)
return payload
}
// controller function
async restController(params: IParams, query: IQuery, body: IBody, headers: any, allData: any): Promise<any> {
// your code here
return new ResponseBuilder('Status', Response, 'Success Message')
}
// socket controller function
socketController(io: Server, socket: Socket, payload: any): any {
// your code here
// Socket data will be available in payload, recieved from the client on socket event, which is setup in the route file
// You can emit data back to the client using io.emit or socket.emit
}
}
export default Controller
import express from 'express'
import Controller from '../Controller'
export default (app: express.Application) => {
// REST Routes
Controller.get(app, '/user', [/* Comma separated middlewares */])
Controller.post(app, '/user', [])
Controller.put(app, '/user/:id', [])
Controller.delete(app, '/user/:id', [])
// Socket Events
// Any payload you send from the client to this event will be available in the socketController function
Controller.socketIO('Event Name')
}
Note: You don't need to import your route file to anywhere, put it in the routes directory, and it will be automatically taken care by the package.
FAQs
Master Controller with automated swagger docs creation for node express app
The npm package node-master-controller receives a total of 0 weekly downloads. As such, node-master-controller popularity was classified as not popular.
We found that node-master-controller 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.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).