Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sundeepk/anon-message-board
https://github.com/sundeepk/anon-message-board
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sundeepk/anon-message-board
- Owner: SundeepK
- Created: 2023-05-04T16:29:23.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-05T17:54:01.000Z (over 1 year ago)
- Last Synced: 2024-11-11T16:06:23.672Z (2 months ago)
- Language: JavaScript
- Size: 116 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Anon board
There exists some simple paths to GET,POST messages for the messages api and also replys to messages:
```
GET http://localhost:3000/api/messages
[
{
"title": "test message reply",
"name": "bob",
"body": "my first reply 2",
"parentId": "0c214e3b-4456-4547-875f-9f1f609e3175",
"rootId": "49be26c6-08c4-497b-887f-05bbd6d67297",
"dateTime": "2023-05-05T17:18:41.138Z",
"id": "23361a57-a45f-480a-857d-265e9aa16f47"
}
]POST http://localhost:3000/api/messages
{
"title": "test message reply",
"name": "bob",
"body": "My message"
}Response
{
"title": "test message reply",
"name": "bob",
"body": "My message",
"parentId": "0c214e3b-4456-4547-875f-9f1f609e3175",
"rootId": "49be26c6-08c4-497b-887f-05bbd6d67297",
"dateTime": "2023-05-05T17:18:41.138Z",
"id": "23361a57-a45f-480a-857d-265e9aa16f47"
}POST http://localhost:3000/api/messages/23361a57-a45f-480a-857d-265e9aa16f47/reply
{
"title": "test message reply",
"name": "bob",
"body": "My first reply 2",
}Response
{
"title": "test message reply",
"name": "bob",
"body": "My first reply 2",
"id": "49be26c6-08c4-497b-887f-05bbd6d67297",
"parentId": "23361a57-a45f-480a-857d-265e9aa16f47",
"rootId": "23361a57-a45f-480a-857d-265e9aa16f47",
}
```## Building and running Docker container
## Building DockerFile
```bash
docker build -t anon-board .
```### Running container
```bash
docker run -it --expose 3000 -p 3000:3000 anon-board
```###
Starting the api without using docker
```
npm run start
```### Running cucumber tests using docker compose
You can run the cucumber tests shipped in the project by running the below command:
```bash
docker-compose up --build --abort-on-container-exit --exit-code-from cucumber
```
It will attempt to build the api server and cucumber tests container, then it will run the cucumber tests that interact with the api server.
Then it will exit the tests and return the last status code of the cucumber container.## Trade-offs
1. In order to complete the project in a timely manner, I opted to simply store messages in memory using a list rather than a DB.
This isn't ideal as the messages disappear once the server is shutdown.
2. No API docs for the project such as swagger.
3. More robust Cucumber tests.
4. DockerFiles are not optimised as they simply copy all files during building.
5. No pagination when requesting messages, this would be troublesome in a prod env.
6. No endpoint to fetch a single message/reply.
7. Better validation for types and length of fields.
8. No user system.
9. Api versioning.