
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
minimal-api
Advanced tools
`Minimal-API` is a sleek and efficient Node.js package for creating HTTP servers. It's designed to be lightweight and dependency-free, offering a streamlined approach to server setup and route management. The package provides `createServer` and `getServer
Minimal-API
is a sleek and efficient Node.js package for creating HTTP servers. It's designed to be lightweight and dependency-free, offering a streamlined approach to server setup and route management. The package provides createServer
and getServer
functions for a seamless development experience.
Install the package via npm:
npm install minimal-api
Initialize your server using createServer
with ES6 syntax:
import { createServer } from "minimal-api";
const port = 4000;
const server = createServer({ port, cors: true }, () => {
console.log(`Server listening on port ${port}`);
});
Option | Type | Description | Default |
---|---|---|---|
port | number | Server listening port. | 4000 |
cors | boolean | Object | Configures CORS. Set to true for default settings, or provide an object for detailed configuration. | false |
serverOptions | http.ServerOptions | Additional options for the HTTP server. | {} |
CORS Object Structure:
Property | Type | Description |
---|---|---|
origin | string | string[] | Specify allowed origins. |
methods | string | string[] | Allowed HTTP methods. |
allowedHeaders | string | string[] | Custom headers that the server will accept. |
exposedHeaders | string | string[] | Headers that are safe to expose to the client. |
credentials | boolean | Indicates whether the request can include user credentials. |
maxAge | number | Maximum age for the CORS settings. |
MinimalRequest Type:
Property | Type | Description |
---|---|---|
url | string | undefined | The request URL. |
method | Method | undefined | The HTTP method used. |
headers | http.IncomingHttpHeaders | The request headers. |
searchParams | URLSearchParams | The URL search parameters. |
params | Record<string, string | undefined> | URL parameters. |
json | () => Promise<T> | Function to get JSON body. |
text | () => Promise<string> | Function to get text body. |
arrayBuffer | () => Promise<ArrayBuffer> | Function to get ArrayBuffer body. |
Handler Type:
Property | Type | Description |
---|---|---|
request | MinimalRequest | The request object. |
Returns | Promise< { contentType?: string; statusCode?: number; data?: any; headers?: Record<string, string>; } | undefined | void > | The response object or void. |
Use addRoute
to define routes on your server with ES6 syntax:
import { MinimalRequest, Handler } from "minimal-api";
const routeHandler: Handler = async (request: MinimalRequest) => {
// Handle the request
// Return response details
};
server.addRoute("get", "/", routeHandler);
Retrieve the server instance anywhere in your code using ES6 imports:
import { getServer } from "minimal-api";
const server = getServer();
// Now use 'server' as needed
Complete example of using minimal-api
to set up a server, add routes, and access the server instance using ES6:
import { createServer, getServer, MinimalRequest, Handler } from "minimal-api";
// Server setup
const server = createServer({ port: 4000, cors: true }, () => {
console.log("Server is running on port 4000");
});
// Adding a route
const helloWorldHandler: Handler = async (request: MinimalRequest) => {
// Handle request and return response details
return {
contentType: "text/plain",
statusCode: 200,
data: "Hello from Minimal-API!",
};
};
server.addRoute("get", "/", helloWorldHandler);
// Accessing the server instance
const serverInstance = getServer();
// Utilize 'serverInstance' as required
Contributions are what make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are immensely appreciated.
Distributed under the MIT License. See LICENSE for more information.
Saiban Ali - @saiban-ali
Project Link: https://github.com/saiban-ali/minimal-api
FAQs
`Minimal-API` is a sleek and efficient Node.js package for creating HTTP servers. It's designed to be lightweight and dependency-free, offering a streamlined approach to server setup and route management. The package provides `createServer` and `getServer
We found that minimal-api 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.