Coder Social home page Coder Social logo

rot_13's Introduction

README

Problem Statement

Using NodeJS, write an API that accepts a post request with a UTF-8 string payload and returns a ROT-13 version of the string, storing the original string in a database of your choice (SQLite, MongoDB, PostgreSQL/MySQL). The API should be capable of accepting a string of 1,000 characters. Then provide an alternate implementation using Ruby on Rails. (No 3rd party libraries or gems may be used for ROT-13.)

Built With


Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • Node v14.17.5
  • Express v4.18.1
  • MongoDB
  • Mongoose v6.4.1
  • Jest v29.2.2

Helping Libraries:

  • body-parser
  • dotenv
  • nodemon

Installation

  1. Clone the repo and cd into it sh git clone https://github.com/salmanali23/rot13.git

  2. Move into the project directory cd rot13

  3. Install dependencies yarn

  4. Start the server

  • yarn run start
  • yarn run dev run with nodemon watch
  1. Run test suits yarn jest

Approach

  • A simple api application to convert the given string to ROT13
  • First check whether rotation of string is in db or not.
  • If is then simply return the encryption in db
  • If not the create hash of each character with it's ROT-13 version on runtime and replace each character of original string
  • After this original and rot13 strings are saved in db
  • API Error Handling added at application level
  • Functional test added in encrypt.spec.js file

API Docs

URL:

  • Method: POST
  • URL: https://API_BASE_URL/api/v1/string_rotation for running local it would become http://localhost:5000/api/v1/string_rotation

Request Payload

{ "stringRotation": { "originalString": "This is a test message" } }

Response Payload

{ "stringRotation": { "originalString": "This is a test message", "rotString": "Guvf vf n grfg zrffntr" } }

rot_13's People

Contributors

salmanali23 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.