
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@capujs/framework
Advanced tools
A framework build declarative and beautifully organizated based in class controllers with decorators usage in Express.js
A framework build declarative and beautifully organizated based in class controllers with decorators usage in Express.js
Install with yarn
yarn add @capujs/framework
#install types
yarn -D add @types/express
yarn -D add @types/cors
Its important enable decorators in you project tsconfig.json
{
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
ExampleController.ts
import { Controller, Get } from "@capujs/framework";
@Controller("/example")
export class ExampleController {
@Get("/")
testMethod() {
return "Hello Word";
}
}
import { createServer} from '@capujs/framework';
import { ExampleController } from './ExampleController';
const app = createServer({
controllers [ExampleController ]
});
//Listen express
const PORT = 3000;
app.listen(PORT,()=> console.log(`Server ready on port ${PORT}`);
Decorator | Example | Description |
---|---|---|
@Controller(prefix?: string) | @Controller("/test") class TestController | Register class with this decorator a registred as controller and its anotated methods are registred. it using express `res.send() |
Decorator | Example | Description |
---|---|---|
@Get(path?:string) | @Get('/users') all() | Method marked with this decorator register a request with GET method |
@Post(path?:string) | @Post('/users') save() | Method marked with this decorator register a request with POST method |
@Put(path?:string) | @Put('/users/:id') update() | Method marked with this decorator register a request with PUT method |
@Patch(path?:string) | @Patch('/users/:id') update() | Method marked with this decorator register a request with PATCH method |
@Delete(path?:string) | @Delete('/users/:id') remove() | Method marked with this decorator register a request with DELETE method |
@Head(path?:string) | @Head('/users/:id') head() | Method marked with this decorator register a request with HEAD method |
@All(path?:string) | @All('/users/:id') all() | Method marked with this decorator register a request with ALL method |
@Options(path?:string) | @Options('/users/:id') all() | Method marked with this decorator register a request with OPTIONS method |
Decorator | Example | Description |
---|---|---|
@Body(options?:IParamOptions) | save(@Body() data: CustomDto) | Inject a body an parameters options can using bodyParser middleware. using req.body |
@BodyParam(name:string, options?:IParamOptions) | save(@BodyParam('name') name:string) | Inject a body an parameters options can using bodyParser middleware. using req.body.name |
@Params() | get(@Params() params: any) | Inject all parameters req.params |
@Param(name:string, options?:IParamOptions) | get(@Param('id') id: string) | Inject a query parameter req.params.id |
@HeaderParams() | get(@HeaderParams() params: any) | Inject all parameters req.headers |
@HeaderParam(name:string, options?:IParamOptions) | get(@HeaderParam("authorization") authorization: string) | Inject a header parameter req.headers.authorization |
@CookieParams() | get(@Cookies( cookies: any) | Inject all cookies parameter req.cookies |
@CookieParam(name:string, options?:IParamOptions) | get(@Cookie("token") token: string) | Inject a cookie parameter req.cookies.token |
@UploadFiles(name:string, options?:IUploadOptions) | post(@UploadFiles("photos") photos: any[]) | Inject multiple upload files from parameter req.files using middleware express-fileupload |
@UploadFile(name:string, options?:IUploadOptions) | post(@UploadFile("photo") photo: any) | Inject single upload file from parameter req.files using middleware express-fileupload |
Decorator | Example | Description |
---|---|---|
@Use(...middleware: RequestHandler[]) | @Use(isAuthenticated) class ProfileController | Register global middleware. |
| Decorator | Example | Description |
| :------------------------------------- | :------------------------------------------------ | :----------------------------------------------- | -------------------------------------------------- |
| @HttpCode(code: number)
| @HttpCode(201) signup()
| Set custom http code after executing successfuly |
| @OnNull(codeOrError: number | Error)
| @OnNull(200) get()
| Set a http code when controller return a null |
| @OnUndefined(codeOrError: number | Error)
| @OnNull(200) get()
| Set a http code when controller return a undefined |
| @Header(name: string, value: string)
| @Header('Authorization','some-token') profile()
| Set a http header after executing successfuly |
FAQs
A framework build declarative and beautifully organizated based in class controllers with decorators usage in Express.js
We found that @capujs/framework 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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.