
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A simple, elegant, yet powerful API handler wrapper for Next.js API routing. It is response-oriented, so it allows you to easily handle errors and return responses in a consistent way.
Some handlers are changing the structure entirely, and I believe most of you will not like that because the expandability is so limited in that way. This handler is simply a wrapper for your original function. It does not change the structure of your function, and it does not change the way you write your logic. It simply wraps your function and handles the response for you, and only it.
Your coding partner will confidently know when you are making a response, how they should make a response, and how to handle errors in the standard way.
Every Next.js developer loves it from day one, so I think you will also enjoy it.
Check out the documentation!
return it everywhere.import { apiHandler, ApiCommonResponse, ApiResponse } from 'mela-api';
// This typing is the same with Next.js API typing definition.
// E.g. `param` for parameters, and `query` for query strings.
// Check Next.js API documentation for more details.
type ReqModel = {
query: {
// Example: Your query parameter.
exampleQuery: string;
},
};
// `string[]` for GET, `null` for POST.
type ResModel = string[] | null;
// `async` is optional.
export default apiHandler<ReqModel, ResModel>(async (req, res) => {
// Unwrap the query parameter confidently with typing.
const { exampleQuery } = req.query;
// Your common logic (e.g. auth handling)...
if (req.method === 'GET') {
// Your GET logic...
// Then return an OK response with data.
return ApiResponse.ok(['Hello', 'World']);
} else if (req.method === 'POST') {
// Your POST logic...
// Then simply return an OK response (based on your logic).
return ApiResponse.ok();
}
// When it is outside of your processing logic,
// it is a METHOD_NOT_ALLOWED response.
return ApiCommonResponse.METHOD_NOT_ALLOWED;
});
npm install mela-api
yarn add mela-api
pnpm add mela-api
METHOD_NOT_ALLOWEDRESTRICTEDNOT_AUTHORIZEDUNKNOWN_ERRORNOT_FOUNDIf there is a common response (except 200 OK) that you think is missing, please open an issue or a pull request.
FAQs
A simple, elegant, yet powerful handler wrapper for Next.js API routing.
We found that mela-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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.