
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
fioc-server-utils
Advanced tools
A lightweight and type-safe utility library for fioc to handle React server features.
FIOC-server-utils (Functional Inversion Of Control - Server Utilities) is a lightweight utility library for FIOC and FIOC React that seamlessly integrates with React Server Components and Server Actions. It provides a type-safe bridge between client components and server-side dependencies, enabling clean architecture in modern React applications.
Install using your preferred package manager:
npm install fioc-server-utils
pnpm install fioc-server-utils
yarn add fioc-server-utils
First, set up your server-side dependency container:
// app/server/container.ts
import { buildDIContainer } from "fioc";
import {
UserRepository,
UserRepositoryToken,
} from "./repositories/userRepository";
import {
CreateUserUseCase,
CreateUserUseCaseToken,
} from "./useCases/createUser";
const serverContainer = buildDIContainer()
.register(UserRepositoryToken, new UserRepository())
.registerFactory({
token: CreateUserUseCaseToken,
dependencies: [UserRepositoryToken],
factory: (repo) => new CreateUserUseCase(repo),
})
.getResult();
Create a Server Action to handle dependency resolution:
// app/server/actions.ts
"use server";
import { buildIoCServerHandler } from "fioc-server-utils";
import { serverContainer } from "./container";
export const iocServerHandler = buildIoCServerHandler(serverContainer);
Set up your client-side container:
// app/client/container.ts
import { buildDIContainer, buildDIManager } from "fioc";
import {
IoCServerHandlerToken,
createServerControllerProxy,
} from "fioc-server-utils";
import { CreateUserUseCaseToken } from "../server/useCases/createUser";
import { iocServerHandler } from "../server/actions";
const clientContainer = buildDIContainer()
.register(IoCServerHandlerToken, iocServerHandler)
.registerFactory(createServerControllerProxy(CreateUserUseCaseToken))
.getResult();
export const DIManager = buildDIManager()
.registerContainer(clientContainer, "default")
.getResult()
.setDefaultContainer("default");
Wrap your app with FIOC-React's provider:
// app/layout.tsx
import { DependenciesProvider } from "fioc-react";
import { DIManager } from "./client/container";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html>
<body>
<DependenciesProvider manager={DIManager}>
{children}
</DependenciesProvider>
</body>
</html>
);
}
Use in components with the useDependencies hook:
// app/components/CreateUser.tsx
"use client";
import { useDependencies } from "fioc-react";
import { CreateUserUseCaseToken } from "../server/useCases/createUser";
export function CreateUserForm() {
const { resolve } = useDependencies();
const createUser = resolve(CreateUserUseCaseToken);
const handleSubmit = async (formData: FormData) => {
try {
await createUser({
name: formData.get("name") as string,
email: formData.get("email") as string,
});
} catch (err) {
// Handle errors
console.error(err);
}
};
return <form action={handleSubmit}>...</form>;
}
Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
MIT License - see the LICENSE file for details.
FAQs
A lightweight and type-safe utility library for fioc to handle React server features.
We found that fioc-server-utils demonstrated a healthy version release cadence and project activity because the last version was released less than 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.