# Modules

## GET /api/v2/getModules

> Get all available modules for Pro users

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/v2/getModules":{"get":{"summary":"Get all available modules for Pro users","tags":["Modules"],"responses":{"200":{"description":"Successfully fetched all modules","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"400":{"description":"Feature restricted to Pro users","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"description":"Unauthorized - User not found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"boolean"}}}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}}}}}
```

## Update a module by its ID

> This endpoint allows users to update a specific module by its \`moduleId\`. The user must be authenticated, and only the user's own modules can be updated.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/modules/{moduleId}":{"put":{"summary":"Update a module by its ID","description":"This endpoint allows users to update a specific module by its `moduleId`. The user must be authenticated, and only the user's own modules can be updated.","tags":["Modules"],"parameters":[{"in":"path","name":"moduleId","required":true,"schema":{"type":"string"},"description":"The ID of the module to be updated."}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"moduleName":{"type":"string","description":"The name of the module."},"moduleRegex":{"type":"string","description":"The regex pattern associated with the module."}}}}},"description":"The module details to update","required":true},"responses":{"200":{"description":"Module updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"object","properties":{"_id":{"type":"string"},"moduleName":{"type":"string"},"moduleRegex":{"type":"string"}}}}}}}},"400":{"description":"Invalid input data","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"404":{"description":"Module not found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"string"}}}}}}}}}}}
```

## Delete a module by its ID

> This endpoint allows users to delete a specific module by its \`moduleId\`. The user must be authenticated, and only the user's own modules can be deleted.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/modules/{moduleId}":{"delete":{"summary":"Delete a module by its ID","description":"This endpoint allows users to delete a specific module by its `moduleId`. The user must be authenticated, and only the user's own modules can be deleted.","tags":["Modules"],"parameters":[{"in":"path","name":"moduleId","required":true,"schema":{"type":"string"},"description":"The ID of the module to be deleted."}],"responses":{"200":{"description":"Module deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"object","properties":{"acknowledged":{"type":"boolean"},"deletedCount":{"type":"integer"}}}}}}}},"404":{"description":"Module not found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}}}}}
```

## Fetch all modules for the authenticated user

> This endpoint retrieves all modules associated with the authenticated user.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/modules":{"get":{"summary":"Fetch all modules for the authenticated user","description":"This endpoint retrieves all modules associated with the authenticated user.","tags":["Modules"],"responses":{"200":{"description":"Modules retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"moduleName":{"type":"string"},"moduleRegex":{"type":"string"}}}}}}}}},"401":{"description":"Unauthenticated user. Login required.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"boolean"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}}}}}
```

## Test module regex against an array of strings

> This endpoint tests a module's regex against an array of test strings and returns the matching results.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/v2/testModules":{"post":{"summary":"Test module regex against an array of strings","description":"This endpoint tests a module's regex against an array of test strings and returns the matching results.","tags":["Modules"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"moduleRegex":{"type":"string"},"test":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"Matches processed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"array","items":{"type":"object","properties":{"moduleRegex":{"type":"string"},"testString":{"type":"string"},"matches":{"type":"string"}}}}}}}}},"400":{"description":"Bad request - validation errors","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"description":"Unauthorized user","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"string"}}}}}}}}}}}
```

## Change module visibility to 'inVerification' and send an email notification

> This endpoint updates the visibility of a specified module to 'inVerification' and sends an email notification to inform about the visibility change.

```json
{"openapi":"3.0.0","info":{"title":"JSMON API","version":"1.0.0"},"servers":[{"url":"https://api-dev.jsmon.sh","description":"Development Server (For internal testing)"},{"url":"https://api.jsmon.sh","description":"Production Server (Stable release)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{}},"paths":{"/api/v2/changeVisibility":{"post":{"summary":"Change module visibility to 'inVerification' and send an email notification","description":"This endpoint updates the visibility of a specified module to 'inVerification' and sends an email notification to inform about the visibility change.","tags":["Modules"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"moduleId":{"type":"string"}}}}}},"responses":{"200":{"description":"Module visibility updated and email sent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"type":"object","properties":{"moduleId":{"type":"string"},"visibility":{"type":"string"}}}}}}}},"400":{"description":"Bad request - missing or invalid fields","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"401":{"description":"Unauthorized user","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"404":{"description":"Module not found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"string"}}}}}}}}}}}
```
