https://github.com/assafelovic/echoattime
A simple server for echoing messages at a given time
https://github.com/assafelovic/echoattime
Last synced: 6 months ago
JSON representation
A simple server for echoing messages at a given time
- Host: GitHub
- URL: https://github.com/assafelovic/echoattime
- Owner: assafelovic
- Created: 2019-12-21T08:48:39.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-22T14:35:00.000Z (almost 6 years ago)
- Last Synced: 2025-02-08T22:43:24.274Z (8 months ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Intro
Write a simple application server (in Node) that prints a message at a given time in the future.
## Requirements
The server has only 1 API:
`echoAtTime` - which receives two parameters, time and message, and writes that message to the server console at the given time.We want the server to be able to withstand restarts so it will use redis to persist the messages and the time they should be sent at.
You should also assume that there will be a cluster of more than one server running behind a load balancer (load balancing implementation itself does not need to be provided as part of the answer)
In case the server was down when a message should have been printed, it should print it out when going back online.
## Usage
Client sends post request with the params `message` (String) and `time` (epoch) to `/api/echo`
```
POST /api/echo
{
time: 1576932753655,
message: "Hello World"
}
```and the server responds with the scheduled message status:
```
{
"message": {
"time": 1576932753655,
"message": "Hello World",
"id": "YZDMN8VV"
},
"success": true,
"scheduledAt": "2019-12-21T12:52:33.655Z"
}
```
At the time of scheduled messages, the server will log accordingly to console.
For example:
```
Message: 'Hello World', Echoed at: Sat Dec 21 2019 14:52:33 GMT+0200 (IST)
```## Install
```
npm i
```## Run
```
npm start
```