
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@cosmoosjs/hono-openapi
Advanced tools
This packages is intented to be injected to @cosmoosjs/core.
It aims to inject an http server and create an api with a simplified integration of Hono Zod OpenApi
$ bun i @cosmoosjs/hono-openapi
Below you'll find the api for understanding some of the existing components
Guards can be used to create middleware using hono middleware.
Regarding the declaration of a guard, it must always be declared before the Get,Post... because of its typescript composition
Typescript
const Guards = (...guard: GuardsType[]): void {}
Usage
@Guards(TestGuard, TestGuard2)
public ...
export class TestGuard extends GuardAbstract {
public run(_ctx: any): void {
console.log("Guard triggered");
}
}
Types
type GuardsType<T extends GuardAbstract = any> = new (...args: any) => T;
abstract class GuardAbstract {
public run(_ctx: Context): void {}
}
All decorators work in the same way and have the same declaration.
const Get = (routeParameters: RouteParameters): void {}
Usage
@Get({
path: '/user/me',
tags: ['User'],
security: [
{
Bearer: [],
}
],
responses: {},
})
Types
type RouteParameters = Omit<OperationObject, "responses"> & {
path: string;
request?: {
body?: ZodRequestBody;
params?: AnyZodObject;
query?: AnyZodObject;
cookies?: AnyZodObject;
headers?: AnyZodObject | ZodType<unknown>[];
};
responses: {
[statusCode: string]: ResponseConfig;
};
};
$ bun test
To test the codebase you need to emulate the process of bootstraping the application. At the moment you can use the helper given below
/**
* Setup environnement for tests
*/
export function setupTestsHelper(container: Container) {
// Bind classes to container
hono_openapi.bindToContainers(container);
core.bindToContainers(container);
bindToContainers(container);
// Get app
const app = container.get(hono_openapi.Server);
// Set reflection for decorators
hono_openapi.defineReflection(app);
// Add custom error handler
hono_openapi.HttpFactory.exceptionHandler(httpExceptionsHandler, container);
// Setup routing
const controllerRoot = container.get(ControllerRoot);
controllerRoot.setup();
}
The helper full declaration is here
This example is from the sample hono-openapi
import { describe, it, beforeAll, expect } from "bun:test";
import { Container } from "inversify";
import { setupTestsHelper } from "src/tests/helpers/setup.helper";
import { Server } from "@cosmoosjs/hono-openapi";
describe("User Controller", () => {
const container = new Container();
beforeAll(() => {
setupTestsHelper(container);
});
it("Should test /", async () => {
const server = container.get(Server);
const res = await server.hono.request("/");
expect(res.status).toEqual(500);
expect(await res.text()).toEqual("Hello my name is error");
});
});
You can have more examples here
FAQs
Http server using hono zod for @cosmoosjs/core
The npm package @cosmoosjs/hono-openapi receives a total of 68 weekly downloads. As such, @cosmoosjs/hono-openapi popularity was classified as not popular.
We found that @cosmoosjs/hono-openapi 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
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.