Skip to content

Commit

Permalink
Add poller and frontend app
Browse files Browse the repository at this point in the history
  • Loading branch information
needs committed Oct 18, 2023
1 parent 037d88d commit 1178e56
Show file tree
Hide file tree
Showing 128 changed files with 14,787 additions and 5,749 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

# Next.js
.next
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}
101 changes: 101 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "silent",
"focus": false,
"panel": "dedicated",
},
"inputs": [
{
"id": "terminateFrontend",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "Frontend"
},
{
"id": "terminatePoller",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "Poller"
},
{
"id": "terminateDocker",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "Docker"
},
],
"tasks": [
{
"label": "Launch local dev",
"dependsOn": [
"Terminate Serve",
"Npm install",
"Start Serve"
],
"dependsOrder": "sequence",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Terminate Serve",
"dependsOn": [
"Terminate Frontend",
"Terminate Poller",
"Terminate Docker"
],
},
{
"label": "Terminate Frontend",
"type": "process",
"command": "echo ${input:terminateFrontend}",
},
{
"label": "Terminate Poller",
"type": "process",
"command": "echo ${input:terminatePoller}",
},
{
"label": "Terminate Docker",
"type": "process",
"command": "echo ${input:terminateDocker}",
},
{
"label": "Npm install",
"type": "shell",
"command": "npm install",
"presentation": {
"close": true
}
},
{
"label": "Start Serve",
"dependsOn": [
"Docker",
"Frontend",
"Poller",
],
},
{
"label": "Docker",
"type": "shell",
"command": "docker compose up",
"isBackground": true,
},
{
"label": "Frontend",
"type": "shell",
"command": "npx nx serve frontend",
"isBackground": true,
},
{
"label": "Poller",
"type": "shell",
"command": "npx nx serve poller",
"isBackground": true,
},
]
}
45 changes: 15 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,30 @@ lastest stable version at teerank.io.

# Run

```bash
# Production
$ docker-compose up --build

# Run tests loop
$ docker-compose -f docker-compose-test.yml -p teerank-dev up --build

# Development server at localhost:80
$ docker-compose -f docker-compose-development.yml -p teerank-test up --build
```

I usually launch tests and the development server on two different shells.
When a source file is changed, tests will be run again and the development
server will be relaunch with the new version. Hence once the containers are
launched there is no need to run them again: just refresh your page in the
browser and check test logs and that's it.
Make sure docker is running and simply build the project in VSCode. For more
informations have a look at the `.vscode/tasks.json` file.

# Legacy

This project is a reboot of teerank.com. The former was written in C and used
SQLite. While good, this technologies are arguably not the best tools in the
box for making a ranking website.
box for making a ranking system.

This project instead relies on Python, Redis and Flask. Performance is not
really a concern so Python is a good language of choice, as it improves
developement speed and is accessible to more people. Redis is handy because
it provides a way to sort our players directly while SQLite doesn't.
This project instead relies on Typescript, NextJS, postgres, redis. Performance
is not really a concern so Typescript is a good language to use, as it improves
developement speed and is accessible to more people. Redis is handy because it
provides a way to sort our players directly while SQLite doesn't.

Finally, the old teerank frontend was a C program compiled into a CGI which
then was plugged into Nginx. It worked, but it was difficult to setup. We
choose to use Flask, because it fit our needs and Flask deals with all the
nasty parts under the hood.
Finally, the old teerank frontend was a C program compiled into a CGI which then
was plugged into Nginx. It worked, but it was difficult to setup. Using NextJS
saves a lot of time and is more flexible.

Also the domain teerank.com expired by accident, and was immediately
cyber-squatted. They refused my buying offers, so at some point I stopped
the server and let the project die. Now the domain is available again but
due to the premium system for .com demains, it costs more than a thousant
dollars, which is not something I want ot pay for a pet project. That's why
teerank is now available at teerank.io.
cyber-squatted. They refused my buying offers, so at some point I stopped the
server and let the project die. Now the domain is available again but due to
the premium system for .com demains, it costs more than a thousand dollars,
which is not something I can afford for a pet project. That's why teerank is
now available at teerank.io.

# Goals

Expand Down
37 changes: 37 additions & 0 deletions apps/frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": [
"plugin:@nx/react-typescript",
"next",
"next/core-web-vitals",
"../../.eslintrc.json"
],
"ignorePatterns": ["!**/*", ".next/**/*"],
"overrides": [
{
"files": ["*.*"],
"rules": {
"@next/next/no-html-link-for-pages": "off"
}
},
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "apps/frontend/pages"]
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
}
}
]
}
3 changes: 3 additions & 0 deletions apps/frontend/app/api/hello/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function GET(request: Request) {
return new Response('Hello, from API!');
}
Loading

0 comments on commit 1178e56

Please sign in to comment.