This is a web service, with REST APIs, that justifies text passed as a parameter
This service provides users required REST APIs that allow:
- JWT-based authentication for obtaining tokens.
- Text justification based on 80 per line.
- Rate limiting for text justification to control usage (80000 word per token per day).
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed.
- Clone this repository.
git clone https://github.com/Sarrabah/justify-text.git
- Navigate to the project directory.
cd justify-text
- Install dependencies.
npm install
- Set the required environment variables by creating a .env file with the following content, and replacing your_secret_key with your desired secret key for JWT token generation:
JWT_SECRET=your_secret_key
- Start the server:
npm run dev
- Method: POST
- Description: Get a JSON Web Token (JWT) by providing an email. You will receive a token in response, which you should include in the Authorization header for subsequent requests.
- Request Body:
{ "email": "foo@bar.com" }
- Response:
{ "token": "your-jwt-token" }
- Method: POST
- Description: Justify text provided in the request body.
- Request Body: Text to be justified, as a plain/text.
- Response: Justified text, as a plain text.
- Contraints: Text justification should be authentificated and it is rate-limited. You will receive a 402 Payment Required status code if you exceed the limit.
A demo has been deployed on a heroku instance URL: https://justify-text-demo-d45e0d48f948.herokuapp.com/
- Have a flexible way to easily configure the width of the line when jutifying text
- Persist the rate limit per token
- Improve the expiration management of the tokens
- Adding more tests, mainly for middlewares