Skip to content

Commit

Permalink
Show topic details
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzie committed Mar 4, 2024
1 parent 52b04c7 commit a111ef9
Show file tree
Hide file tree
Showing 15 changed files with 513 additions and 339 deletions.
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,7 @@ paket-files/
__pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/
tools/Cake.CoreCLR
.vscode
tools
.dotnet
Dockerfile

# .env file contains default environment variables for docker

.git/


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
return AuthenticateResult.NoResult();
}

if (string.IsNullOrEmpty(Request.Headers["Authorization"]) && string.IsNullOrEmpty(Request.Headers["X-API-KEY"]))
if (string.IsNullOrEmpty(Request.Headers["Authorization"]) && string.IsNullOrEmpty(Request.Headers["X-API-KEY"]))
{
return AuthenticateResult.Fail("Missing Authorization or X-API-KEY header");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ public async Task<ActionResult<string>> AddMessage(string? topicId, [FromBody] s
var msg = new Message() { TopicId = topicId, Content = message };
await Store.AddMessageAsync(msg);

return Ok(topicId);
}
/// <summary>
/// Creates a message under topic id.
/// </summary>
/// <param name="topicId">If topicId is null, a new Topic will be generated with a random GUID</param>
/// <param name="message"></param>
/// <returns>Topic Id</returns>
[ProducesResponseType<string>(StatusCodes.Status200OK)]
[Authorize(Roles = "write")]
[HttpPost(Name = nameof(AddMessage))]
public async Task<ActionResult<string>> AddMessage(string? topicId, [FromBody] string message)
{
if (string.IsNullOrEmpty(message))
return BadRequest($"{nameof(message)} cannot be null");
if (string.IsNullOrEmpty(topicId))
topicId = Guid.NewGuid().ToString();
var msg = new Message() { TopicId = topicId, Content = message };
await Store.AddMessageAsync(msg);

return Ok(topicId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public async Task<ActionResult<Topic>> GetTopic(string topicId)
}



[ProducesResponseType(StatusCodes.Status200OK)]
[Authorize(Roles = "write")]
[HttpDelete("{topicId}/messages/{messageId}", Name = nameof(DeleteMessage))]
Expand Down
3 changes: 3 additions & 0 deletions Source/Topica.UI/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
2 changes: 2 additions & 0 deletions Source/Topica.UI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
"react": "^18.2.0",
"react-auth-kit": "^3.0.1",
"react-dom": "^18.2.0",
"react-infinite-scroll-component": "^6.1.0",
"react-router-dom": "^6.22.0"
},
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@types/react": "^18.2.51",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.20.0",
Expand Down
129 changes: 111 additions & 18 deletions Source/Topica.UI/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a111ef9

Please sign in to comment.