1.0.3 • Published 1 year ago
code-snippet-organizer v1.0.3
Code Snippet Organizer API
Installation
npm install code-snippet-organizer --save
API
Table of Contents
- createServer
- POST /api/snippets
- GET /api/snippets
- GET /api/snippets/:id
- PUT /api/snippets/:id
- DELETE /api/snippets/:id
createServer
Create and configure the server to manage code snippets.
Example Usage
const snippetOrganizer = require('code-snippet-organizer');
const app = snippetOrganizer();
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
POST /api/snippets
Create a new code snippet.
Parameters
title (String): The title of the snippet.
code (String): The code content of the snippet.
language (String): The programming language of the snippet.
tags (Array): List of tags associated with the snippet.
Example Request Body
{
"title": "REST API Example",
"code": "console.log(\"Implementing RESTful API with Node.js\");",
"language": "JavaScript",
"tags": ["REST", "API", "example"]
}
GET /api/snippets
Retrieve all code snippets.
GET /api/snippets/:id
Retrieve a specific code snippet by ID.
PUT /api/snippets/:id
Update a specific code snippet by ID.
Example Request Body
{
"title": "Updated Snippet",
"code": "console.log(\"Updated code snippet\");",
"language": "JavaScript",
"tags": ["updated", "snippet"]
}