Skip to content

Commit 3ac0760

Browse files
committed
Merge branch 'release/0.4.0' into main
2 parents 83c8146 + 97c47a7 commit 3ac0760

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1760
-1168
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22

33
## [UNRELEASED]
44

5+
### Added
6+
- Add Transmit to handle Server-Side Events.
7+
- Setup general chat room.
8+
- Add Api service to handle api requests.
9+
- Add Scheduler service to handle scheduled tasks :
10+
- Matchmaking
11+
- Add Matchmaking service to handle matchmaking.
12+
- Add Game Controller to handle game logic.
13+
- Add Client page to handle view of the game.
14+
515
## [0.3.0] - 2024-05-07
616

17+
### Added
18+
719
- Add `TailwindCSS` to the project.
820
- Setup `Redis` to handle session storage.
921
- Add `docker-compose.yaml` to the project to handle PostgreSQL and Redis in development environment.

LICENSE

Lines changed: 208 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Mind Reader Game
2+
3+
## Description
4+
Website that allows users to play a mind reader game.
5+
6+
The game is simple, one user have a word given and the other person have to guess the word using other words.
7+
8+
## Technologies
9+
- AdonisJS
10+
- SSR with AdonisJS (InertiaJS - React)
11+
- TailwindCSS
12+
- Redis
13+
- PostgreSQL
14+
- Docker
15+
16+
## How to run
17+
1. Clone the repository
18+
2. Run `pnpm install`
19+
3. Copy `.env.example` to `.env` and fill the variables
20+
4. Run `docker-compose up -d`
21+
5. Run `pnpm dev`
22+
6. Access `http://localhost:3333`
23+
24+

adonisrc.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
| will be scanned automatically from the "./commands" directory.
1111
|
1212
*/
13-
commands: [() => import('@adonisjs/core/commands'), () => import('@adonisjs/lucid/commands')],
13+
commands: [() => import('@adonisjs/core/commands'), () => import('@adonisjs/lucid/commands'), () => import('adonisjs-scheduler/commands')],
1414

1515
/*
1616
|--------------------------------------------------------------------------
@@ -40,7 +40,12 @@ export default defineConfig({
4040
() => import('@adonisjs/inertia/inertia_provider'),
4141
() => import('@adonisjs/i18n/i18n_provider'),
4242
() => import('@adonisjs/redis/redis_provider'),
43-
() => import('@adonisjs/ally/ally_provider')
43+
() => import('@adonisjs/ally/ally_provider'),
44+
() => import('@adonisjs/transmit/transmit_provider'),
45+
{
46+
file: () => import('adonisjs-scheduler/scheduler_provider'),
47+
environment: ['console'],
48+
}
4449
],
4550

4651
/*
@@ -51,7 +56,10 @@ export default defineConfig({
5156
| List of modules to import before starting the application.
5257
|
5358
*/
54-
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
59+
preloads: [() => import('#start/routes'), () => import('#start/kernel'), {
60+
file: () => import('#start/scheduler'),
61+
environment: ['console'],
62+
}],
5563

5664
/*
5765
|--------------------------------------------------------------------------

app/controllers/home_controller.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/controllers/login_controller.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

config/transmit.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from '@adonisjs/transmit'
2+
import { redis } from '@adonisjs/transmit/transports'
3+
import env from '#start/env'
4+
5+
export default defineConfig({
6+
pingInterval: false,
7+
transport: {
8+
driver: redis({
9+
host: env.get('REDIS_HOST'),
10+
port: env.get('REDIS_PORT'),
11+
password: env.get('REDIS_PASSWORD'),
12+
}),
13+
},
14+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BaseSchema } from '@adonisjs/lucid/schema'
2+
3+
export default class extends BaseSchema {
4+
protected tableName = 'roles'
5+
6+
async up() {
7+
this.schema.createTable(this.tableName, (table) => {
8+
table.increments('id')
9+
table.string('name').notNullable()
10+
11+
table.timestamp('created_at')
12+
table.timestamp('updated_at')
13+
})
14+
15+
this.defer(async () => {
16+
await this.db.table('roles').insert([{ name: 'user' }, { name: 'admin' }])
17+
})
18+
}
19+
20+
async down() {
21+
this.schema.dropTable(this.tableName)
22+
}
23+
}

database/migrations/1714567006854_create_users_table.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ export default class extends BaseSchema {
44
protected tableName = 'users'
55

66
async up() {
7+
const roleId = await this.db.from('roles').where('name', 'user').select('id').first()
78
this.schema.createTable(this.tableName, (table) => {
89
table.uuid('id').defaultTo(this.raw('gen_random_uuid()')).primary()
910
table.string('username').notNullable()
1011
table.string('email', 254).notNullable().unique()
1112
table.timestamp('email_verified_at').nullable()
1213
table.string('password').nullable()
1314
table.string('avatar_url').nullable()
15+
table.integer('elo').defaultTo(500)
16+
table
17+
.integer('role_id')
18+
.unsigned()
19+
.notNullable()
20+
.references('id')
21+
.inTable('roles')
22+
.defaultTo(roleId.id)
1423
table
1524
.smallint('provider_id')
1625
.unsigned()
@@ -24,6 +33,8 @@ export default class extends BaseSchema {
2433
table.string('last_session_id').nullable()
2534
table.timestamp('last_session_at', { useTz: true }).nullable()
2635

36+
table.timestamp('banned_at').nullable()
37+
2738
table.timestamp('created_at').notNullable()
2839
table.timestamp('updated_at').nullable()
2940
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BaseSchema } from '@adonisjs/lucid/schema'
2+
3+
export default class extends BaseSchema {
4+
protected tableName = 'words'
5+
6+
async up() {
7+
this.schema.createTable(this.tableName, (table) => {
8+
table.uuid('id').defaultTo(this.raw('gen_random_uuid()')).primary()
9+
table.string('name').notNullable()
10+
table.integer('found_count').defaultTo(0)
11+
table.integer('played_count').defaultTo(0)
12+
table.integer('difficulty').defaultTo(0)
13+
table.string('language').notNullable()
14+
15+
table.timestamp('created_at')
16+
table.timestamp('updated_at')
17+
})
18+
}
19+
20+
async down() {
21+
this.schema.dropTable(this.tableName)
22+
}
23+
}

0 commit comments

Comments
 (0)