0.2.0 • Published 1 year ago
code-sample-test v0.2.0
Code Sample API
Code Sample API is a lightweight Node.js package that sets up a server to expose doc's code as API endpoints. Simply provide the path to the folder containing your doc's code data file, and the package does the rest!
Features
- Generate language-specific code.
- Configurable server port (default is
8080). - Easy to set up with a single command.
Installation
You don't need to install the package globally; use npx to run it directly:
npx code-sample-api <folder-path> [port]Usage
Basic Example
To start the server:
- Place your code sample data in a folder, e.g.,
./data. Run the following command:
npx code-sample-api ./dataBy default, the server will start at http://localhost:8080.
Query Parameters
languages: Comma-separated list of languages (e.g.,csharp,java,php).version: Specify the version of the code sample data.
Supported languages:
csharpjavaphppythonrubytypescriptgohttp
Custom Port
You can specify a custom port by providing it as the second argument:
npx code-sample-api ./data -p 3000The server will now run at http://localhost:3000.
Accessing the API
To access the API, use the provided portal link. The exact URL depends on your server configuration.
Requirements
- Node.js (version 20 or higher)