Skip to content

Commit d7746bf

Browse files
committed
Merge branch 'public_website'
2 parents 08728c9 + 88922fe commit d7746bf

File tree

9 files changed

+49
-28
lines changed

9 files changed

+49
-28
lines changed

.github/workflows/deploy-app.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ jobs:
2929
- name: 🔍 Install dependencies
3030
run: cd app && npm install
3131

32+
- name: 📝 Setup Production .env File
33+
run: cd app && cp .env.example .env
34+
3235
- name: 🧱 Build application
33-
run: cd app && npm run build
36+
run: |
37+
cd app
38+
npm run build
39+
cp .env dist/.env
3440
3541
- name: 📤 Deploy to VPS
3642
uses: easingthemes/ssh-deploy@main

api/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MYSQL_HOST=localhost
1313
MYSQL_PORT=3306
1414
MYSQL_USER=leo
1515
MYSQL_PASSWORD=root
16-
COMPOSE_PROJECT_NAME=ApartEasy
16+
COMPOSE_PROJECT_NAME=apart-easy
1717
GOOGLE_CLIENT_ID=19************4f.apps.googleusercontent.com
1818
GOOGLE_CLIENT_SECRET=GOCSPX-9ZQd**********
1919
GOOGLE_CALLBACK_URL=http://localhost:3333/api/oauth2/google/callback
@@ -27,7 +27,7 @@ APP_URL=http://localhost:5173
2727
APP_DOMAIN=aparteasy.dibodev.com
2828
APP_NAME=ApartEasy
2929
APP_LOGO=https://i.ibb.co/qRDCDjm/apart-easy.png
30-
APP_PRIMARY_COLOR="#ff2560"
30+
APP_PRIMARY_COLOR="#db0a61"
3131
APP_EMAIL_NO_REPLY=[email protected]
3232
APP_EMAIL_SUPPORT=[email protected]
3333
SESSION_DRIVER=cookie

api/.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ [email protected]
99
APP_EMAIL_SUPPORT=[email protected]
1010
APP_LOGO=https://i.ibb.co/qRDCDjm/apart-easy.png
1111
APP_NAME=ApartEasy
12-
APP_PRIMARY_COLOR="#ff2560"
12+
APP_PRIMARY_COLOR="#db0a61"
1313
APP_URL=https://aparteasy.dibodev.com
1414
DB_CONNECTION=mysql
1515
MYSQL_DATABASE=

api/app/Services/FakeService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default class FakeService {
22
public static generateRandomHexColor(): string {
33
const letters = '0123456789ABCDEF'
4-
let color = '#'
4+
let color = ''
55
for (let i = 0; i < 6; i++) {
66
color += letters[Math.floor(Math.random() * 16)]
77
}
@@ -10,8 +10,8 @@ export default class FakeService {
1010

1111
public static generateDiceBearURL(name: string, avatarStyle = 'adventurer'): string {
1212
const backgroundColor = encodeURIComponent(this.generateRandomHexColor())
13-
return `https://avatars.dicebear.com/api/${avatarStyle}/${encodeURIComponent(
13+
return `https://api.dicebear.com/7.x/${avatarStyle}/svg?seed=${encodeURIComponent(
1414
name
15-
)}.svg?background=${backgroundColor}`
15+
)}&backgroundColor=${backgroundColor}`
1616
}
1717
}

api/config/app-infos.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Env from '@ioc:Adonis/Core/Env'
22
export default {
3-
color: Env.get('APP_PRIMARY_COLOR', '#ff2560'),
4-
name: Env.get('APP_NAME', 'My App'),
3+
color: Env.get('APP_PRIMARY_COLOR', '#db0a61'),
4+
name: Env.get('APP_NAME', 'ApartEasy'),
55
logo: Env.get('APP_LOGO'),
66
url: Env.get('APP_URL'),
77
domain: Env.get('APP_DOMAIN'),

api/database/migrations/1682443424189_searches_user_to_creator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class SearchesUpdateUserIdToCreatorId extends BaseSchema {
88
table.integer('creator_id').unsigned().after('location_id')
99
})
1010

11-
await this.defer(async (db) => {
11+
this.defer(async (db) => {
1212
await db.rawQuery('UPDATE searches SET creator_id = user_id')
1313
})
1414

@@ -24,7 +24,7 @@ export default class SearchesUpdateUserIdToCreatorId extends BaseSchema {
2424
table.integer('user_id').unsigned().after('location_id')
2525
})
2626

27-
await this.defer(async (db) => {
27+
this.defer(async (db) => {
2828
await db.rawQuery('UPDATE searches SET user_id = creator_id')
2929
})
3030

api/database/migrations/1690232737281_remove_location_id_from_searches.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ export default class RemoveLocationIdFromSearches extends BaseSchema {
88
const hasColumn = await this.schema.hasColumn(this.tableName, 'location_id')
99
if (hasColumn) {
1010
await Database.rawQuery('ALTER TABLE searches DROP FOREIGN KEY searches_location_id_foreign')
11-
await this.schema.table(this.tableName, (table) => {
12-
table.dropColumn('location_id')
13-
})
1411
}
1512
}
1613

1714
public async down() {
1815
const hasColumn = await this.schema.hasColumn(this.tableName, 'location_id')
19-
2016
if (!hasColumn) {
2117
await this.schema.table(this.tableName, (table) => {
2218
table
@@ -26,7 +22,9 @@ export default class RemoveLocationIdFromSearches extends BaseSchema {
2622
.inTable('locations')
2723
.onDelete('CASCADE')
2824
})
29-
await Database.rawQuery('ALTER TABLE searches ADD CONSTRAINT searches_location_id_foreign FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE CASCADE')
25+
await Database.rawQuery(
26+
'ALTER TABLE searches ADD CONSTRAINT searches_location_id_foreign FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE CASCADE'
27+
)
3028
}
3129
}
3230
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
2+
import User from 'App/Models/User'
3+
import FakeService from 'App/Services/FakeService'
4+
5+
export default class ReplaceDiceBearAvatarOldVersion extends BaseSchema {
6+
protected tableName = 'users'
7+
8+
public async up() {
9+
// Find all users with old dicebear avatar (e.g., https://avatars.dicebear.com/api/adventurer/Vernon%20Patterson.svg?background=%23392FF7)
10+
const users: User[] = await User.query()
11+
.where('avatar_url', 'LIKE', '%avatars.dicebear.com%')
12+
.exec()
13+
14+
// Replace old dicebear avatar with new dicebear avatar
15+
for (const user of users) {
16+
user.avatarUrl = FakeService.generateDiceBearURL(user.name)
17+
await user.save()
18+
}
19+
}
20+
21+
public async down() {}
22+
}

api/database/seeders/01_FakeDatas.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import UserLocation from 'App/Models/UserLocation'
1212

1313
export default class FakeDatasSeeder extends BaseSeeder {
1414
public async run() {
15+
let createdUsers: Array<User> = []
16+
1517
// Create users
1618
const maxUsers: number = 10
1719
const existingUsers: Array<User> = await User.all()
1820
if (existingUsers.length < maxUsers) {
1921
const users = generateUsers(maxUsers)
20-
await User.createMany(users)
22+
createdUsers = await User.createMany(users)
2123
}
2224

2325
// Create locations
@@ -40,17 +42,10 @@ export default class FakeDatasSeeder extends BaseSeeder {
4042
const maxSearches: number = 10
4143
const existingSearches: Array<Search> = await Search.all()
4244
if (existingSearches.length < maxSearches) {
43-
// 10 users
44-
const createdUsers: Array<User> = await User.all()
45-
const tenUsers: Array<User> = createdUsers.slice(0, 10)
46-
47-
// 10 searches
48-
const createdSearches: Array<Search> = await Search.all()
49-
const tenSearches: Array<Search> = createdSearches.slice(0, 10)
50-
const searches = await generateSearches(maxSearches, tenUsers)
51-
await Search.createMany(searches)
52-
await addUsersToSearches(tenSearches, createdUsers)
53-
await addPropertiesToSearches(tenSearches)
45+
const searches = await generateSearches(maxSearches, createdUsers)
46+
const createdSearches = await Search.createMany(searches)
47+
await addUsersToSearches(createdSearches, createdUsers)
48+
await addPropertiesToSearches(createdSearches)
5449
}
5550
}
5651
}

0 commit comments

Comments
 (0)