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

Alpha preparation #4

Merged
merged 85 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
bd39cf8
npm workspaces, NodeNext for server
Feb 5, 2023
b6957f2
include package-lock.json
Feb 5, 2023
acf029b
use remix eslint config
Feb 5, 2023
1fb4ff6
update readme
Feb 5, 2023
3cc1a77
ignore package-lock.json
Feb 6, 2023
4676a99
env variables for easier dev setup
Feb 6, 2023
015977a
update server deps
Feb 6, 2023
c03cf47
init remix app
Feb 6, 2023
09cfd71
Merge branch 'main' into dev
Feb 6, 2023
22f1314
update main field in server package.json
Feb 6, 2023
209ebbf
update server deps
Feb 13, 2023
862cada
switch to next.js
Feb 13, 2023
31d7a7a
ignore .vscode folder
Feb 15, 2023
4324ee6
update client deps
Feb 15, 2023
2ef5e33
use next.js 13 appdir, add initial navbar drawer
Feb 15, 2023
5d731c5
lowercase c for page title
Feb 18, 2023
393353a
update deps, add tabler icons
Feb 19, 2023
0f7cc7a
add custom daisyUI themes
Feb 19, 2023
a39d68d
temp avatar image
Feb 19, 2023
8c5c3a0
navbar and footer design
Feb 19, 2023
374dda2
homepage design
Feb 19, 2023
13c7515
update readme
Feb 20, 2023
c6be8f0
separate into more components
Feb 20, 2023
8ee8ba8
initial game page design
Feb 20, 2023
e7fec4f
update readme
Feb 20, 2023
44d95f5
rename api url env variable
Feb 20, 2023
3ccbd57
layout adjustments to fit screen height
Feb 24, 2023
d9e5c81
move components to separate folder
Feb 25, 2023
ebc8c66
update deps
Feb 25, 2023
a61b012
use new metadata api
Feb 25, 2023
19fb1a9
move css to styles folder
Feb 25, 2023
44d460b
remove winner field from db
Mar 1, 2023
3d3e765
update public games layout
Mar 2, 2023
e562d53
use modal for auth nav button
Mar 2, 2023
181738a
general layout improvements
Mar 2, 2023
77a6325
update deps
Mar 2, 2023
572eb22
Merge branch 'main' into dev
Mar 2, 2023
6dc9f1a
update game endpoints
Mar 4, 2023
6f7a9fa
session context & auth util functions
Mar 4, 2023
7c4ef84
add config file for api url
Mar 4, 2023
e6436fe
initial guest auth functionality
Mar 4, 2023
6de9943
game util functions
Mar 4, 2023
dd0a097
initial find & create game functionality
Mar 4, 2023
f3eaf23
use req.params directly
Mar 4, 2023
997cbac
update readme
Mar 4, 2023
b7ee6f4
rename to getGame & improve error handling
Mar 4, 2023
9ca2d7b
wrap game page in server component
Mar 4, 2023
eb40d73
add optional deps to suppress socketio error msgs
Mar 4, 2023
01ebc4a
rename game wrapper, add initial socket events
Mar 5, 2023
69fb7a7
add wrapper component to check auth
Mar 5, 2023
5699663
don't remove player on disconnect
Mar 5, 2023
a616911
add optional deps to server
Mar 5, 2023
09ddb6e
update optional dep
Mar 5, 2023
247a6c1
initial playable functionality
Mar 5, 2023
fa94df1
show error tooltip when game not found
Mar 5, 2023
a30331c
public games list functionality
Mar 5, 2023
802e5bb
btn-disabled instead of loading to preserve size
Mar 5, 2023
82ca279
improve player names format
Mar 5, 2023
a9accad
add metadata and opengraph tags
Mar 6, 2023
72a80fe
remove home route background
Mar 6, 2023
167e1cb
add temporary 404 page
Mar 6, 2023
045470b
navbar site name changes
Mar 6, 2023
dd1166d
open badge dropdown on hover
Mar 6, 2023
4e17ead
wrap auth util functions in try blocks
Mar 6, 2023
fe0e045
show player disconnected state
Mar 6, 2023
754d149
session id detection improvements
Mar 6, 2023
ef9e233
restore link in navbar and separate badge dropdown
Mar 6, 2023
0a3fd53
leaveLobby improvements
Mar 6, 2023
158aef5
improve moveFrom safety
Mar 6, 2023
fd66897
start pgn with empty string
Mar 6, 2023
c548f10
cleanup comment
Mar 6, 2023
d858853
move validation fixes, update page title on turn
Mar 6, 2023
6071686
remove extra comment
Mar 6, 2023
d913a25
update light theme neutral color
Mar 6, 2023
da1a556
add theme toggle functionality
Mar 6, 2023
f086239
add swap animation to theme toggle
Mar 6, 2023
7fea5f9
adjust light theme secondary color
Mar 6, 2023
b98e4a2
redirect on client for 404
Mar 6, 2023
99b73fb
scrollbar styling
Mar 6, 2023
4e3e77e
adjust game inactivity time to 15 minutes
Mar 6, 2023
19880c0
chat messages styling
Mar 6, 2023
440e8cd
exclude ended games from public api
Mar 6, 2023
6d19501
add required pattern for guest name
Mar 6, 2023
caa12fd
check pattern in backend as well
Mar 6, 2023
7d704a9
show dropdown when link copied
Mar 6, 2023
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
33 changes: 1 addition & 32 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
{
"settings": {
"react": {
"version": "detect"
}
},
"root": true,
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
]
}
"extends": ["next", "prettier"]
}
72 changes: 55 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,70 @@
# chessu

> ❗ This project is currently undergoing a major refactor in the `dev` branch. (see [#4](https://github.com/nizewn/chessu/pull/4))
> ❗ This project is still in the early stages of development and should be considered unstable. Expect bugs and weird behavior.

Online 2-player chess. Live demo at [ches.su](https://ches.su)
Yet another Chess web app. Live demo at [ches.su](https://ches.su).

- React 18
- CSS Modules
- [react-chessboard](https://github.com/Clariity/react-chessboard)
- [chess.js](https://github.com/jhlywa/chess.js)
- Express.js
- socket.io
- PostgreSQL
- play against other users in real-time
- spectate and chat in ongoing games with other users
- ~~_optional_ user accounts for tracking stats and game history~~ (wip)
- mobile-friendly (wip)

## Development
Built with Next.js 13, Tailwind CSS + daisyUI, react-chessboard, chess.js, Express.js, socket.io and PostgreSQL.

This repository is used for production deployments. You will need to make changes to the configuration to get this running locally.
## Configuration

This project is structured as a monorepo using npm workspaces, separated into three packages:

- `client` - Next.js application for the front-end, deployed to [ches.su](https://ches.su).
- `server` - Node/Express.js application for the back-end, deployed to [api.ches.su](https://api.ches.su).
- `types` - Shared type definitions for the client and server.

### Scripts

```sh
npm install # install all dependencies
# install all dependencies, including eslint and prettier for development
npm install

# concurrently run frontend and backend development servers
npm run dev # -w client/server to run only one

npm run dev # concurrently run frontend and backend dev servers

npm run react-dev # run frontend server only
# for separate production deployments
npm install -w client
npm install -w server

npm run build -w client
npm run build -w server

npm start -w client
npm start -w server
```

For separate deployments, you may exclude the `client` or `server` directory. However, you should include the `types` folder as it contains shared type definitions that are required by both packages.

### Environment variables

Client: `APIURL` (or just change `apiUrl` in `/client/src/config/config.ts`)
You may create a `.env` file in each package directory to set their environment variables.

Server: `PORT`, `SESSION_SECRET`, `PGUSER`, `PGPASSWORD`, `PGHOST`, `PGDATABASE`, `PGPORT`
(also see server cors config and session middleware for local development)
client:

```env
NEXT_PUBLIC_API_URL=http://localhost:3001 # replace with backend URL
```

server:

```env
CORS_ORIGIN=http://localhost:3000 # replace with frontend URL
PORT=3001
SESSION_SECRET=randomstring # replace for security

# PostgreSQL connection info
PGHOST=db.example.com
PGUSER=exampleuser
PGPASSWORD=examplepassword
PGDATABASE=chessu

# or use a connection string instead
DATABASE_URL=postgres://...
```
37 changes: 37 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem
.vscode/

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
13 changes: 0 additions & 13 deletions client/index.html

This file was deleted.

9 changes: 9 additions & 0 deletions client/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
appDir: true
}
};

module.exports = nextConfig;
43 changes: 25 additions & 18 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
{
"name": "chessu",
"private": true,
"name": "@chessu/client",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@radix-ui/colors": "^0.1.8",
"@radix-ui/react-icons": "^1.1.1",
"@tabler/icons-react": "^2.7.0",
"chess.js": "^1.0.0-beta.3",
"react": "^18.2.0",
"react-chessboard": "^2.0.8",
"react-dom": "^18.2.0",
"react-router-dom": "^6.8.1",
"socket.io-client": "^4.6.0"
"next": "13.2.3",
"react": "18.2.0",
"react-chessboard": "^2.1.0",
"react-dom": "18.2.0",
"socket.io-client": "^4.6.1"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.1.0",
"typescript": "^4.9.5",
"vite": "^4.1.1"
"@chessu/types": "*",
"@types/node": "18.14.6",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.11",
"autoprefixer": "^10.4.13",
"daisyui": "^2.51.3",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.7",
"typescript": "4.9.5"
},
"optionalDependencies": {
"bufferutil": "^4.0.7",
"utf-8-validate": "^6.0.3"
}
}
6 changes: 6 additions & 0 deletions client/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
Binary file added client/public/assets/default_avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 0 additions & 104 deletions client/public/chessu.svg

This file was deleted.

32 changes: 0 additions & 32 deletions client/src/App.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions client/src/app/game/[code]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function NotFound() {
return (
<div className="flex flex-col items-center justify-center gap-4">
<div className="text-2xl font-bold">Error</div>
<div className="text-xl">Game not found</div>
</div>
);
}
Loading