Git Product home page Git Product logo

tiktok-tech-immersion-2023-assignment's Introduction

Tests

2023 TikTok Tech Immersion Backend Assignment

0. Introduction

This is a submission of the backend assignment of 2023 TikTok Tech Immersion, based upon the demo template.

The HTTP server serves as an interface for users, in which it connects with a micoservice RPC server which uses Redis database to store the messages.

1. Setting up

Run the following command the same directory as docker-compose.yml to initialise the necessary Docker containers:

docker compose up -d

2. Syntax

2.1 Sending messages

To send a message, we send a POST request to localhost:8080/api/send, specifying the following URL parameters:

  • chat: Name of chat in the form [USER A]:[USER B]
  • sender: Name of sender
  • text: Text in message

Example To send "hi" from a to b, we use the following command:

curl -X POST 'localhost:8080/api/send?chat=a:b&sender=a&text=hi'

2.2 Pulling messages

To send a message, we send a GET request to localhost:8080/api/pull, specifying the following URL parameters:

  • chat: Name of chat in the form [USER A]:[USER B]
  • cursor: Earliest epoch time of messages to retrieve, 0 by default
  • limit: Maximum number of messages to retrieve, 10 by default
  • reverse: Boolean value of whether to sort messages in ascending order by time

Example To retrieve all messages between a and b (i.e., chat a:b), we use the following command:

curl 'localhost:8080/api/pull?chat=a:b&cursor=0&limit=10&reverse=false'
  • Although we specified cursor as 0 and limit as 10, here, we could omit them. The request will default to cursor=0 and limit=10 respectively.

tiktok-tech-immersion-2023-assignment's People

Contributors

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