Official Claude Code plugins for the Zyket framework
npx claudepluginhub pemakz/zyketClaude Code plugin for the Zyket framework — scaffold handlers, guards, routes, middlewares, services, events, schedulers, workers, and extensions.
Zyket is a Node.js framework designed to simplify the development of real-time applications with Socket.IO and Express. Inspired by the structured approach of frameworks like Symfony, Zyket provides a robust, service-oriented architecture for building scalable and maintainable server-side applications.
Upon initial boot, Zyket automatically scaffolds a default project structure, including handlers, routes, and configuration files, allowing you to get started immediately.
To begin using Zyket, install it in your project:
npm i zyket
Then, create an index.js file and boot the Zyket Kernel:
// index.js
const { Kernel } = require("zyket");
// Instantiate the kernel
const kernel = new Kernel();
// Boot the kernel to start all services
kernel.boot().then(() => {
console.log("Kernel booted successfully!");
});
When you run this for the first time, Zyket will create a default .env file and a src directory containing boilerplate for routes, handlers, guards, and middlewares.
Zyket is built around a few key architectural concepts:
Handlers are classes that process incoming Socket.IO events. The name of the handler file (e.g., message.js) determines the event it listens to (message).
// src/handlers/message.js
const { Handler } = require("zyket");
module.exports = class MessageHandler extends Handler {
// Array of guard names to execute before the handler
guards = ["default"];
async handle({ container, socket, data, io }) {
const logger = container.get("logger");
logger.info(`Received message: ${JSON.stringify(data)}`);
socket.emit("response", { received: data });
}
};
Guards are used to protect Socket.IO handlers or the initial connection. They run before the handler's handle method and are ideal for authorization logic.
// src/guards/default.js
const { Guard } = require("zyket");
module.exports = class DefaultGuard extends Guard {
async handle({ container, socket, io }) {
container.get("logger").info(`Executing default guard for socket ${socket.id}`);
// Example: Check for an auth token. If invalid, disconnect the user.
// if (!socket.token) {
// socket.disconnect();
// }
}
};
Routes handle HTTP requests. The file path maps directly to the URL endpoint. For example, src/routes/index.js handles requests to /, and src/routes/[test]/message.js handles requests to /:test/message.
// src/routes/index.js
const { Route } = require("zyket");
const DefaultMiddleware = require("../middlewares/default");
module.exports = class DefaultRoute extends Route {
// Apply middlewares to specific HTTP methods
middlewares = {
get: [ new DefaultMiddleware() ],
post: [ new DefaultMiddleware() ]
}
async get({ container, request }) {
container.get("logger").info("Default route GET");
return { test: "Hello World GET!" };
}
async post({ container, request }) {
container.get("logger").info("Default route POST");
return { test: "Hello World POST!" };
}
};
Middlewares process the request before it reaches the route handler. They follow the standard Express middleware pattern.
// src/middlewares/default.js
const { Middleware } = require("zyket");
module.exports = class DefaultMiddleware extends Middleware {
async handle({ container, request, response, next }) {
container.get("logger").info("Default Express middleware executing");
next(); // Pass control to the next middleware or route handler
}
};
Services are the cornerstone of Zyket's architecture, providing reusable functionality across your application. Zyket includes several default services and allows you to register your own.
You can create your own services by extending the Service class and registering it with the Kernel.
// src/services/MyCustomService.js
const { Service } = require("zyket");
module.exports = class MyCustomService extends Service {
constructor() {
super("my-custom-service");
}
async boot() {
console.log("MyCustomService has been booted!");
}
doSomething() {
return "Something was done.";
}
}
Register the service in your main index.js file:
// index.js
const { Kernel } = require("zyket");
const MyCustomService = require("./src/services/MyCustomService");