/trapi-nestjs

Translate API using nestjs

Primary LanguageTypeScript

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Translation API using AWS Translate api.

Installation

Make .env file from .env.example.

$ cp .env.example .env

Fill in AWS access key, secret and region.

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

The development API server will be hosted on http://127.0.0.1:3000.

Use curl to test the API.

$ curl -H "Content-Type: application/json" -d '{"text": "bonjour!"}' -X POST http://127.0.0.1:3000/translate

API Documentation

Method: POST
Url: /translate
Payload:
{
  "text": "<text to translate>",
  "sourceLangCode": "<language code>", // default "auto"
  "targetLangCode": "<lagnuage code>"  // default "en"
}

To get more information about the language codes, please check this AWS documentation.

License

Nest is MIT licensed.