Giter VIP home page Giter VIP logo

encrypt-chat-server's Introduction

Encrypt chat server

key features

  • This project consists of 4 APIs, User registration, User Login, Send messages and Get messages.
  • Application have a simple encryption and decryption functionality to store the messages exchanged between the users.
  • Messages cannot be readable directly from the database. It should be only readable from the application when any of the users enter the secret key.
  • Make sure the encryption is based on logic not directly using any of the libraries.
  • Used JWT for authentication and authorization, also assigned iat and exp to the JWT token. Sended token to the header as x-api-key.
  • Created a branch named Project/ChatServer and followed all the naming convention in order to convey my work efficiently.

Models

  • User Model
{
   name : {String,required},
   contacts: { [String],required },
   phone: { String, required, unique },
   secretKey : { String, required },
   timestamps : {createdAt, updatedAt}
}
  • Message Model
{
    sender: {String, required },
    text: {  String,  required},
    recipient: {  String, required},
    timestamps : {createdAt, updatedAt}
}

User APIs

POST /registerUser

  • Create a user document from request body. Request body must contain Name, contacts, phone and secretkey.
  • HTTP status code 201 for successful registration , 400 for any server error.
  • Response format
{
    "status": true,
    "message": "User created successfully",
    "data": {
        "name": "John Doe",
        "contacts": ["abc","xyz","pqr"],
        "phone": "7141456986",
        "secretkey": "123xyz00@"
        "_id": "6162876abdcb70afeeaf9cf5",
        "createdAt": "2021-10-10T06:25:46.051Z",
        "updatedAt": "2021-10-10T06:25:46.051Z",
        "__v": 0
    }
}
  • Postman sample A Postman collection sample

POST /login

  • Allow an user to login only with their phone and secretKey.
  • On a successful OTP sended note send the response message as shown below.
  • Response format
{
    "status": true,
    "message": "User login successful.",
    data : [
        userId : "6162876abdcb70afeeaf9cf5",
        token : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2MjA0MDUwZDliZWQzMTU3YTc3MTk2YTIiLCJpYXQiOjE2NDQ0MzA3NDgsImV4cCI6MTY0NDUxNzE0OH0.cCcWwWEmKTyihzUjeJWcRefFfxz2fgDgw-oJaRimK7w"
    ]
}
  • Postman sample A Postman collection sample

Messages APIs

POST /sendMessage

  • A sender can send messgaes to a recipient, who must be present in the sender's contacts.
  • Response format
{
    "status": true,
    "message": "Message sent successfully.",
    "data": {
        "sender": "abc",
        "text": "�~���9����z�",
        "recipient": "xyz",
        "_id": "620fa36024b96c9d0aa3d927",
        "createdAt": "2022-02-18T13:47:12.493Z",
        "updatedAt": "2022-02-18T13:47:12.493Z",
        "__v": 0
    }
}
  • Postman sample A Postman collection sample

GET/getMessage/:userId

  • Recipients can fetch all their messages by using the query filters and putting the sender's name into it.
  • Response format
{
    "status": true,
    "message": "3 messages from nik",
    "data": {
        "from": "nik",
        "msg": [
            "oh bhai",
            "hi !",
            "hello vishal"
        ]
    }
}
  • Postman sample A Postman collection sample

  • MongoDB sample A MongoDB collection sample A MongoDB collection sample

encrypt-chat-server's People

Contributors

tushar-1001 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.