A powerful NestJS-based API for text paraphrasing with multiple styles and strategies.
npm install
Copy the example environment file:
cp .env.example .env
Configure your environment variables in .env:
PORT=3000
USE_ADVANCED_PARAPHRASE=false
OPENAI_API_KEY=your_openai_api_key_here # Optional
HUGGINGFACE_API_KEY=your_huggingface_api_key_here # Optional
# Development
npm run start:dev
# Production
npm run build
npm run start:prod
The API will be available at http://localhost:3000
Paraphrase a single text.
Request Body:
{
"text": "This is the text you want to paraphrase.",
"style": "formal",
"targetLanguage": "en"
}
Response:
{
"originalText": "This is the text you want to paraphrase.",
"paraphrasedText": "This is the content you wish to rephrase.",
"style": "formal",
"confidence": 0.85,
"alternativeVersions": [
"This is the content you desire to rephrase.",
"This represents the text you wish to paraphrase."
],
"processingTime": 145,
"wordCount": 8,
"characterCount": 42
}
Paraphrase multiple texts at once (max 10 per request).
Request Body:
[
{
"text": "First text to paraphrase.",
"style": "simple"
},
{
"text": "Second text to paraphrase.",
"style": "formal"
}
]
Get available paraphrasing styles and their descriptions.
Response:
{
"styles": ["simple", "formal", "casual", "creative", "academic"],
"descriptions": {
"simple": "Basic paraphrasing with synonym replacement",
"formal": "Professional tone with complete sentences",
"casual": "Conversational style with contractions",
"creative": "Engaging language with varied structures",
"academic": "Scholarly tone with precise vocabulary"
}
}
Get paraphrasing history (placeholder endpoint).
Health check endpoint.
| Style | Description | Example |
|---|---|---|
simple | Basic synonym replacement | "big" β "large" |
formal | Professional, complete sentences | "can't" β "cannot" |
casual | Conversational with contractions | "cannot" β "can't" |
creative | Varied sentence structures | Restructures sentences creatively |
academic | Scholarly vocabulary | "show" β "demonstrate" |
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 3000 |
USE_ADVANCED_PARAPHRASE | Enable AI paraphrasing | false |
OPENAI_API_KEY | OpenAI API key | - |
HUGGINGFACE_API_KEY | HuggingFace API key | - |
ALLOWED_ORIGINS | CORS allowed origins | http://localhost:3000 |
The API supports two main strategies:
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov
src/
βββ paraphraser/
β βββ dto/ # Data Transfer Objects
β βββ strategies/ # Paraphrasing strategies
β βββ paraphraser.controller.ts
β βββ paraphraser.service.ts
β βββ paraphraser.module.ts
βββ app.module.ts
βββ main.ts
ParaphraseStrategy interfaceParaphraserModule providersParaphraserService to use the new strategyThe API returns structured error responses:
{
"error": "Paraphrasing Failed",
"message": "Text must be at least 5 characters long",
"statusCode": 400,
"timestamp": "2025-10-06T12:00:00.000Z"
}
# Simple paraphrasing
curl -X POST http://localhost:3000/paraphrase \
-H "Content-Type: application/json" \
-d '{
"text": "The quick brown fox jumps over the lazy dog.",
"style": "formal"
}'
# Bulk paraphrasing
curl -X POST http://localhost:3000/paraphrase/bulk \
-H "Content-Type: application/json" \
-d '[
{"text": "Hello world!", "style": "casual"},
{"text": "Goodbye world!", "style": "formal"}
]'
const response = await fetch('http://localhost:3000/paraphrase', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'This is a test sentence.',
style: 'creative',
}),
});
const result = await response.json();
console.log(result.paraphrasedText);
This project is licensed under the MIT License.
Nest framework TypeScript starter repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deploy
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Check out a few resources that may come in handy when working with NestJS:
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
35 commits
Python
52.5%
TypeScript
43.7%
JavaScript
1.6%
Shell
1.5%
A powerful NestJS-based API for text paraphrasing with multiple styles and strategies.
npm install
Copy the example environment file:
cp .env.example .env
Configure your environment variables in .env:
PORT=3000
USE_ADVANCED_PARAPHRASE=false
OPENAI_API_KEY=your_openai_api_key_here # Optional
HUGGINGFACE_API_KEY=your_huggingface_api_key_here # Optional
# Development
npm run start:dev
# Production
npm run build
npm run start:prod
The API will be available at http://localhost:3000
Paraphrase a single text.
Request Body:
{
"text": "This is the text you want to paraphrase.",
"style": "formal",
"targetLanguage": "en"
}
Response:
{
"originalText": "This is the text you want to paraphrase.",
"paraphrasedText": "This is the content you wish to rephrase.",
"style": "formal",
"confidence": 0.85,
"alternativeVersions": [
"This is the content you desire to rephrase.",
"This represents the text you wish to paraphrase."
],
"processingTime": 145,
"wordCount": 8,
"characterCount": 42
}
Paraphrase multiple texts at once (max 10 per request).
Request Body:
[
{
"text": "First text to paraphrase.",
"style": "simple"
},
{
"text": "Second text to paraphrase.",
"style": "formal"
}
]
Get available paraphrasing styles and their descriptions.
Response:
{
"styles": ["simple", "formal", "casual", "creative", "academic"],
"descriptions": {
"simple": "Basic paraphrasing with synonym replacement",
"formal": "Professional tone with complete sentences",
"casual": "Conversational style with contractions",
"creative": "Engaging language with varied structures",
"academic": "Scholarly tone with precise vocabulary"
}
}
Get paraphrasing history (placeholder endpoint).
Health check endpoint.
| Style | Description | Example |
|---|---|---|
simple | Basic synonym replacement | "big" β "large" |
formal | Professional, complete sentences | "can't" β "cannot" |
casual | Conversational with contractions | "cannot" β "can't" |
creative | Varied sentence structures | Restructures sentences creatively |
academic | Scholarly vocabulary | "show" β "demonstrate" |
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 3000 |
USE_ADVANCED_PARAPHRASE | Enable AI paraphrasing | false |
OPENAI_API_KEY | OpenAI API key | - |
HUGGINGFACE_API_KEY | HuggingFace API key | - |
ALLOWED_ORIGINS | CORS allowed origins | http://localhost:3000 |
The API supports two main strategies:
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov
src/
βββ paraphraser/
β βββ dto/ # Data Transfer Objects
β βββ strategies/ # Paraphrasing strategies
β βββ paraphraser.controller.ts
β βββ paraphraser.service.ts
β βββ paraphraser.module.ts
βββ app.module.ts
βββ main.ts
ParaphraseStrategy interfaceParaphraserModule providersParaphraserService to use the new strategyThe API returns structured error responses:
{
"error": "Paraphrasing Failed",
"message": "Text must be at least 5 characters long",
"statusCode": 400,
"timestamp": "2025-10-06T12:00:00.000Z"
}
# Simple paraphrasing
curl -X POST http://localhost:3000/paraphrase \
-H "Content-Type: application/json" \
-d '{
"text": "The quick brown fox jumps over the lazy dog.",
"style": "formal"
}'
# Bulk paraphrasing
curl -X POST http://localhost:3000/paraphrase/bulk \
-H "Content-Type: application/json" \
-d '[
{"text": "Hello world!", "style": "casual"},
{"text": "Goodbye world!", "style": "formal"}
]'
const response = await fetch('http://localhost:3000/paraphrase', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'This is a test sentence.',
style: 'creative',
}),
});
const result = await response.json();
console.log(result.paraphrasedText);
This project is licensed under the MIT License.
Nest framework TypeScript starter repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deploy
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Check out a few resources that may come in handy when working with NestJS:
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
35 commits
Python
52.5%
TypeScript
43.7%
JavaScript
1.6%
Shell
1.5%