About EndpointX

EndpointX is an open-source project available on GitHub.

You can view the source code, report issues, suggest ideas,
or contribute to the project

https://github.com/robnsiov/endpointx

If you find a bug, have an improvement idea, want to help
improve the documentation, or have any feedback, feel free to contact me.

Email: robnsiov@gmail.com

Thank you for supporting open-source development ❤️ .

Ctrl+K

Frequently Asked Questions

This page provides answers to the most common questions about building and troubleshooting mock APIs with EndpointX.

General

Can I use EndpointX as my production backend?

No. EndpointX is explicitly designed for frontend UI development, mobile app prototyping, mock APIs, and testing. Code executes inside an isolated sandbox with strict memory and execution boundaries. It cannot handle production traffic or scale like a traditional backend server.

See the limitations for a detailed breakdown of runtime constraints.

How do I authenticate my requests?

Every HTTP request made to an EndpointX route from your client application must include
endpoint-x: TOKEN header. If this header is missing, the platform will reject the request before it reaches your endpoint code.

Runtime and Code Execution

Can I install npm packages like lodash or mongoose?

No. To guarantee a secure and instantaneous execution environment. You can only write pure ECMAScript (JavaScript). The platform does not support import statements, require(), or any external npm packages. You also do not have access to Node.js core modules (like fs or crypto).

Why do I receive a "Response must be an object." or "Status is invalid."?

Your endpoint code must always return an object in every situation.

The returned object must include a valid status property. This is required for the system to correctly handle the response.

Example:

return {
  status: 200,
};

Can I use a different function name than the HTTP method?

No. The function name in your endpoint code must match the HTTP method.

For example, if your endpoint method is POST, your code must define:

export async function POST() {
  return {
    status: 200,
  };
}

How can I secure my third-party API keys?

Never hardcode sensitive credentials directly in your endpoint code. You should store API keys, webhook secrets, and configuration flags as Environment Variables. They are injected into your sandbox and can be accessed via the process.env object.

See environment variables for configuration instructions.

Network and Data

How is my data persisted?

EndpointX provides a built-in JSON Database exposed via the global db object. You can treat db as a standard JavaScript object. You can read, update, add, or delete data directly from this object.

Database changes are not persisted automatically. If you modify the db object during execution, you must include db in the returned response object so EndpointX can detect and persist the changes for future API requests.

Because the database resides in the same sandbox memory space as your endpoint code, it is intended strictly for lightweight mock data.

Why did my axios() request crash or timeout?

Outbound network requests made using the injected axios() API are subject to an 8-second timeout limit. If the third-party service you are trying to reach takes longer than 8 seconds to respond, the platform will forcibly abort the request.

Always wrap your axios() calls in a try/catch block to handle upstream network failures gracefully.

How do I read route parameters like /users/:id?

Dynamic path parameters are automatically extracted and placed into the globally available params object. Query string parameters (e.g., ?sort=desc) are placed in the searchParams object.

export async function GET() {
  // Path: /users/:id
  const userId = params.id;
  const sortBy = searchParams.sort;
 
  return {
    status: 200,
    body: {
      requestedId: userId,
      sorting: sortBy,
    },
  };
}