Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer #11

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.8'

services:
app:
image: node:20.17.0
container_name: apigpt
working_dir: /usr/src/app
volumes:
- .:/usr/src/app
ports:
- "${EXPRESS_PORT}:${EXPRESS_PORT}"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the ${EXPRESS_PORT} environment variable is defined in your .env file to avoid runtime errors.

command: npm run dev
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command npm run dev should be verified to ensure it is correctly set up in your package.json.

env_file:
- .env

# mongo:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the commented-out section for the mongo service if it is not going to be used, to keep the file clean.

# image: mongo:latest
# container_name: mongo
# ports:
# - "27017:27017"
# volumes:
# - mongo_data:/data/db

# volumes:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous comment, if the mongo_data volume is not needed, it should be removed to avoid confusion.

# mongo_data:
5 changes: 2 additions & 3 deletions src/helper/gpt/tool/database/aiRepository.tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const aiRepositoryTool = {
query: {
type: 'object',
description:
'The query parameters used for the operation. Structure depends on the transaction type, Required for update operations. Include subpropeties query.filter and query.update',
'The query parameters used for the operation. Structure depends on the transaction type.',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for the query parameters is incomplete. It should mention that it is required for update operations and include details about the subproperties query.filter and query.update.

properties: {
filter: {
type: 'object',
Expand All @@ -23,8 +23,7 @@ const aiRepositoryTool = {
},
update: {
type: 'object',
description:
'Data to update. Required for update operations. Include subpropeties query.filter and query.update',
description: 'Data to update (required for update transactions).',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description should be more specific about the required subproperties for the update operation. Consider including details about query.filter and query.update to avoid confusion.

},
},
required: ['filter'],
Expand Down
39 changes: 31 additions & 8 deletions src/helper/swagger/path/ai/ai.swagger.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,52 @@
export default {
'/ai': {
post: {
summary: 'Processa a requisição AI',
description: 'Envia uma requisição para o serviço AI.',
summary: 'Interact with AI for API Commands',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The summary and description have been changed to English, which is good for consistency, but the previous summary was more concise. Consider revising the summary to be more succinct.

description:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new description is quite lengthy. It might be beneficial to condense the information to focus on the most critical aspects of the endpoint.

'This endpoint allows users to send natural language commands to the API. You can use this to perform various actions such as creating users, fetching products, or retrieving information. Here are some examples of how to structure your commands:\n' +
'- "Create a user named John Doe with email john.doe@example.com."\n' +
'- "Find all products under $50."\n' +
'- "Show me details of the user named Jane Smith."\n' +
'- "List all users."',
tags: ['AI Command Interface'],
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
body: {
type: 'object',
},
header: {
type: 'object',
prompt: {
type: 'string',
example:
'Create a product named Sample Product with description "This is a sample product." and price 19.99.',
},
},
required: ['prompt'],
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The required field should be defined in the schema object, but it is currently placed outside of the properties object. Please ensure it is correctly nested.

},
},
},
},
responses: {
200: {
description: 'Resposta bem-sucedida',
description: 'Response from the API based on the provided command',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
response: {
type: 'string',
description:
'The result of the command interpreted and executed by the API.',
},
},
},
},
},
},
400: {
description: 'Invalid command, please check your input.',
},
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for the 400 response should be more informative. Consider specifying what kind of input might lead to an invalid command.

},
},
Expand Down
187 changes: 187 additions & 0 deletions src/helper/swagger/path/product/product.swagger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
export default {
'/products': {
get: {
summary: 'Fetch All Products',
description:
'Retrieves a list of all products with optional filtering and pagination.',
tags: ['JSON'], // Tag para agrupar na seção JSON
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in this line is in Portuguese. It would be better to keep comments in English for consistency.

parameters: [
{
name: 'priceMin',
in: 'query',
description: 'Minimum price to filter products',
required: false,
schema: {
type: 'number',
},
},
{
name: 'priceMax',
in: 'query',
description: 'Maximum price to filter products',
required: false,
schema: {
type: 'number',
},
},
{
name: 'page',
in: 'query',
description: 'Page number for pagination',
required: false,
schema: {
type: 'integer',
example: 1,
},
},
{
name: 'limit',
in: 'query',
description: 'Number of products per page',
required: false,
schema: {
type: 'integer',
example: 10,
},
},
],
responses: {
200: {
description: 'List of products retrieved successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
total: {
type: 'integer',
description: 'Total number of products available',
},
products: {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
},
description: {
type: 'string',
},
price: {
type: 'number',
},
stock: {
type: 'number',
},
category: {
type: 'string',
},
},
},
},
},
},
},
},
},
},
},
},
'/product/name/{name}': {
get: {
summary: 'Fetch Specific Product by Name',
description: 'Retrieves details of a specific product by its name.',
tags: ['JSON'], // Tag para agrupar na seção JSON
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to line 7, this comment is also in Portuguese. Please ensure all comments are in English.

parameters: [
{
name: 'name',
in: 'path',
required: true,
description: 'Name of the product to retrieve',
schema: {
type: 'string',
},
},
],
responses: {
200: {
description: 'Product details retrieved successfully',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
},
description: {
type: 'string',
},
price: {
type: 'number',
},
stock: {
type: 'number',
},
category: {
type: 'string',
},
},
},
},
},
},
},
},
},
'/product': {
post: {
summary: 'Create Product',
description:
'Creates a new product by sending product details in JSON format.',
tags: ['JSON'], // Tag para agrupar na seção JSON
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this comment is in Portuguese. Consistency in language is important, so please translate it to English.

requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: {
type: 'string',
example: 'Sample Product',
},
description: {
type: 'string',
example: 'This is a sample product description.',
},
price: {
type: 'number',
example: 29.99,
},
stock: {
type: 'number',
example: 100,
},
category: {
type: 'string',
example: 'Electronics',
},
},
required: ['name', 'description', 'price', 'category'],
},
},
},
},
responses: {
201: {
description: 'Product created successfully',
},
400: {
description: 'Invalid input',
},
},
},
},
};
Loading
Loading