Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Room based chat example, built with React and Socketioxide. #211

Merged
merged 6 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/react-rooms-chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
18 changes: 18 additions & 0 deletions examples/react-rooms-chat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "chatly"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
socketioxide = { version = "0.9.0", features = ["state"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = "0.3"
axum = "0.7.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tower-http = {version = "0.5.0", features = ["cors"]}
tower = "0.4"
chrono = { version = "0.4", features = ["serde"] }
10 changes: 10 additions & 0 deletions examples/react-rooms-chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Chatly, A room based group chat app built with React and Socketioxide.
This repo provides the backend and frontend for the Rust Socket.io video by
[Dreams of Code](https://youtube.com/@dreamsofcode).

The building instructions for the client can be found in the `client` folder.

To run the server, `cd` into this directory and run `cargo run` command.

App Screenshot:
![App Screenshot](app-screenshot.png)
Binary file added examples/react-rooms-chat/app-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions examples/react-rooms-chat/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: {browser: true, es2020: true},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: {ecmaVersion: 'latest', sourceType: 'module'},
settings: {react: {version: '18.2'}},
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{allowConstantExport: true},
],
"react/prop-types": "off"
},
}
24 changes: 24 additions & 0 deletions examples/react-rooms-chat/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
23 changes: 23 additions & 0 deletions examples/react-rooms-chat/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
This repo provides the frontend for the Rust Socket.io video by
[Dreams of Code](https://youtube.com/@dreamsofcode).

## Requirements

- Node v18
- npm

## Usage

1. Fisrt `cd` into this directory.
2. Then install the depencencies using npm

```shell
$ npm install
```
3. Finally, run the development server

```shell
$ npm run dev
```

You should see the client running on http://localhost:5173
13 changes: 13 additions & 0 deletions examples/react-rooms-chat/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chatly</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading