Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.
Draft
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ coverage

/target
/Cargo.lock
/apps/web/build.zip
/apps/web/build.zip
1 change: 0 additions & 1 deletion apps/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ DATABASE_PORT=5432
DATABASE_NAME='databaseName'
DATABASE_USERNAME='user'
DATABASE_PASSWORD='password'
ENCRYPT_KEY='MySuperPassword!MySuperPassword!'

POSTGRES_USER=postgres
POSTGRES_PW=postgres
Expand Down
7 changes: 6 additions & 1 deletion apps/api/src/helpers/getCookieFromToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { API_ERRORS, ApiError } from '@api'
import type { DiaryUserId, Nullable } from '@diary-spo/shared'
import type { Nullable } from '@diary-spo/shared'
import { formatDate } from '@utils'
import { caching } from 'cache-manager'
import { authSaveUseDate } from 'src/models/Auth/actions/save'
import { AuthModel, type AuthModelType } from '../models/Auth'
import { DiaryUserModel, type DiaryUserModelType } from '../models/DiaryUser'
import { GroupModel, type GroupModelType } from '../models/Group'
Expand Down Expand Up @@ -75,6 +77,9 @@ export const getCookieFromToken = async (
throw new ApiError(API_ERRORS.INVALID_TOKEN, 401)
}

if (diaryUserAuth.lastUsedDate !== formatDate(new Date()))
authSaveUseDate(token, new Date())

const user = diaryUserAuth.diaryUser
const spoId = user.group.spo.id

Expand Down
17 changes: 17 additions & 0 deletions apps/api/src/models/Auth/actions/save/authSaveUseDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { formatDate } from '@utils'
import { AuthModel, IAuthModel } from '../../model'

export const authSaveUseDate = async (
token: string,
date: Date
): Promise<[affectedCount: number]> =>
AuthModel.update(
{
lastUsedDate: formatDate(date)
},
{
where: {
token
}
}
)
1 change: 1 addition & 0 deletions apps/api/src/models/Auth/actions/save/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './authSaveUseDate'
10 changes: 7 additions & 3 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
"deploy:vk": "vk-miniapps-deploy",
"lint": "biome lint . --apply",
"format": "biome format . --write",
"checkAll": "biome check . --write --unsafe"
"checkAll": "biome check . --write --unsafe",
"buildIcons": "bun tauri icon ./src-tauri/icons/app-icon.png",
"generateWindowsBuildKey": "bunx tauri signer generate -w ./src-tauri/keys/forUpdate.key",
"generateAndroidKey": "keytool -genkey -v -keystore ./src-tauri/keys/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload"
},
"dependencies": {
"@elysiajs/eden": "1.1.3",
"@tauri-apps/cli": "^2.1.0",
"@vkontakte/icons": "2.137.0",
"@vkontakte/vk-bridge": "^2.15.2",
"@vkontakte/vk-bridge-react": "^1.0.1",
"@vkontakte/vk-mini-apps-router": "1.4.6",
"@vkontakte/vkui": "6.6.0",
"bun": "^1.1.34",
"date-fns": "^3.6.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"bun": "^1.1.34"
"react-dom": "^18.3.1"
},
"devDependencies": {
"@diary-spo/shared": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
/keys/forUpdate.key
/keys/upload-keystore.jks
Loading