
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.
Simple typescript mock server with memory context
.
npm i moccu --save-dev
.
Run the server by command
moccu
.
Create and configure moccu.config.ts file at project root. Or it will created automatically on the first start.
import type { Config } from 'moccu';
const config: Config = {
/**
* Server port
*/
port: 3000,
/**
* API url prefix
*/
base: '',
/**
* List of mocked routes
*/
routes: [],
/**
* Logger level
*/
logger: 'main',
};
export default config;
.
./__mocks__/get-user.ts
import type { Route, Request } from 'moccu';
const route: Route = {
/**
* Request path
*/
path: '/user/:userId',
/**
* Request method
*/
method: 'get',
/**
* Response status
*/
status: 200,
/**
* Response body
*/
response: (req: Request) => {
return {
text: `Hello, ${req.params.userId}`,
};
},
/**
* Response delay
*/
delay: 100,
};
export default route;
./moccu.config.ts
import type { Config } from 'moccu';
import getUser from './__mocks__/get-user';
const config: Config = {
port: 3000,
base: '/api',
routes: [
getUser,
],
};
export default config;
.
We can change mock responses based on the global context between requests.
./moccu.config.ts
import type { Config, Request } from 'moccu';
import { Context } from 'moccu';
type MockContext = {
name: string;
};
const config: Config = {
port: 3000,
base: '/api',
routes: [
{
method: 'get',
path: '/greet',
response: () => {
const ctx = Context.use<MockContext>('testContext');
return {
message: `Hello, ${ctx.name ?? 'Noname'}!`,
};
},
},
{
method: 'put',
path: '/rename',
response: (req: Request) => {
const ctx = Context.use<MockContext>('testContext');
ctx.name = req.body.value ?? 'Unnamed';
},
},
],
};
export default config;
FAQs
Simple typescript mock server with memory context
We found that moccu demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.