Giter Club home page Giter Club logo

api-assignment's Introduction

English to French Translation API

This project provides a simple API for translating English text to French using the free-translate library. The API is built with Express.js and includes a translation service and controller.

Getting Started

To use this API, follow the steps below:

  1. Clone the repository:

    git clone https://github.com/priyanshusingh305/api-assignment.git
  2. Install dependencies:

    cd translation-api
    npm install
  3. Start the server:

    npm start

    The API will be accessible at http://localhost:5454.

API Endpoints

Translate English to French

  • Endpoint: /translate/engtofr

  • Method: POST

  • Request Body:

    {
      "text": "Enter your English text here"
    }
  • Response:

    • Status Code: 201

    • Body:

      {
        "translation": "Your translated text in French"
      }
    • Status Code: 400 (Bad Request)

      • Body:

        {
          "error": "Text to translate is required"
        }
    • Status Code: 500 (Internal Server Error)

      • Body:

        {
          "error": "Failed to translate text"
        }

Project Structure

  • /services/translation.service.js: Translation service containing the logic for English to French translation.
  • /controller/translate.controller.js: Controller handling the translation request.
  • /routes/translate.route.js: Express router defining the API endpoint and connecting it to the controller.
  • app.js: Main application file, setting up the Express app, defining routes, and starting the server.

Dependencies

Usage

Visit http://localhost:5454 to access the API and follow the provided endpoint documentation for translation.

Feel free to explore and modify the code to suit your needs!

api-assignment's People

Contributors

priyanshusingh305 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.