Easy to use, fast and lightweight library for Node.js.
🚧 This project is under development and is not yet ready for use.
- 💡 About
- 🚀 Tecnologies
- 👷 How to run
- 📖 Documentation
- 🤝 How to Contribute
- 📝 License
JTP is a protocol for transferring data between systems. It facilitates communication between systems using JSON (JavaScript Object Notation) as the data format and relies on the TCP/IP protocol for data transfer.
The following tools were used in the construction of the project:
npm install @geisonjr/json-transfer-protocolor using yarn
yarn add @geisonjr/json-transfer-protocol# Host address of the client
CLIENT_HOST=127.0.0.1
# Port the client will use
CLIENT_PORT=6969
# Indicates if the client uses a secure connection
CLIENT_SECURE=true# Host address of the server
SERVER_HOST=127.0.0.1
# Port the server will use
SERVER_PORT=6969
# Indicates if the server uses SSL for secure connections
SERVER_SECURE=true
# Path to the server SSL certificate
SERVER_CERT=/certs/cert.pem
# Path to the server SSL key
SERVER_KEY=/certs/key.pem
# Path to the Certificate Authority (CA) certificate
SERVER_CA=/certs/ca.pem# Directory where logs will be stored
LOG_DIR=./logs
# Enables or disables logging
LOG=false
# Maximum size of the log file
LOG_MAX=1000000
# Defines if logs will be displayed in the console
LOG_CONSOLE=true
# Defines if logs will be formatted as JSON
LOG_JSON=false
# Defines if logs will be formatted as text
LOG_LOG=false
# Enables or disables DEBUG log level
LOG_DEBUG=true
# Enables or disables INFO log level
LOG_INFO=true
# Enables or disables WARN log level
LOG_WARN=true
# Enables or disables ERROR log level
LOG_ERROR=true
# Enables or disables FATAL log level
LOG_FATAL=true
# Enables or disables TRACE log level
LOG_TRACE=trueimport { Server, Status } from '@geisonjr/json-transfer-protocol';
const server = new Server({
port: 6969
});
server.start();
server.create('/api/test', (req, res) => {
const name = req.body.data.name;
res.status = Status.OK;
res.body = {
type: 'string',
data: `Hello, ${name}`
};
});import { fetcher } from '@geisonjr/json-transfer-protocol';
const response = await fetcher({
head: {
host: 'example.com',
method: 'CREATE',
path: '/api/test'
},
body: {
type: 'object',
data: {
name: 'Geison',
age: 23
}
}
});
if (!response.success) {
console.error(response.data);
return;
}
console.log(response.data);Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
This project is under the MIT License.
{ "head": { "host": "example.com:6969", "method": "CREATE", "path": "/api/v1" }, "body": { "type": "string", "data": "Hello World!!" } }