diff --git a/apps/browser/src/hooks/useLoginForm.ts b/apps/browser/src/hooks/useLoginForm.ts index 2dc6078..e1febb0 100644 --- a/apps/browser/src/hooks/useLoginForm.ts +++ b/apps/browser/src/hooks/useLoginForm.ts @@ -74,60 +74,21 @@ export function useLoginForm({ onSubmitSuccess }: UseLoginFormProps = {}) { setIsLoading(true) console.log('Submitting login data:', formData) - // --- TODO: Replace with actual API call to your RageMP server --- try { - // Example: Simulate API call - await new Promise(resolve => setTimeout(resolve, 1000)) - - // Assuming API returns success: - console.log('Login successful!') - // Here you would typically receive a token or session info - // Handle 'saveLogin' and 'savePassword' (e.g., using localStorage/sessionStorage) - if (formData.saveLogin) { - localStorage.setItem('savedUsername', formData.identifier) // Example - } else { - localStorage.removeItem('savedUsername') // Example - } - // Password saving is generally discouraged for security reasons, - // but if required: - if (formData.savePassword) { - // Be VERY careful with storing passwords. Consider secure storage or tokens. - // localStorage.setItem('savedPassword', formData.password); // **Highly discouraged** - console.warn( - 'Password saving enabled - ensure secure storage mechanism.', - ) - } - setErrors({}) // Clear errors on success if (onSubmitSuccess) { onSubmitSuccess(formData) // Call success callback } - // You might redirect the user or update application state here - - // --- Mock Error Handling (remove in real implementation) --- - // if (formData.identifier === 'wrong') { - // throw new Error("Invalid credentials."); - // } - // --- End Mock Error Handling --- } catch (apiError: unknown) { console.error('Login API error:', apiError) setSubmitError('Login failed. Please check your credentials.') } finally { setIsLoading(false) } - // --- End API call section --- }, [formData, validateForm, onSubmitSuccess], ) - // Effect to potentially load saved username on initial render (example) - // useEffect(() => { - // const savedUser = localStorage.getItem('savedUsername'); - // if (savedUser) { - // setFormData(prev => ({ ...prev, identifier: savedUser, saveLogin: true })); - // } - // }, []); - return { formData, errors, diff --git a/apps/browser/src/hooks/useRegisterForm.ts b/apps/browser/src/hooks/useRegisterForm.ts index 77b83ad..157b00f 100644 --- a/apps/browser/src/hooks/useRegisterForm.ts +++ b/apps/browser/src/hooks/useRegisterForm.ts @@ -74,13 +74,7 @@ export function useRegisterForm({ setIsLoading(true) console.log('Submitting registration data:', formData) - // --- TODO: Replace with actual API call to your RageMP server --- try { - // Example: Simulate API call - await new Promise(resolve => setTimeout(resolve, 1500)) - - // Assuming API returns success: - console.log('Registration successful!') setFormData({ username: '', email: '', @@ -92,20 +86,12 @@ export function useRegisterForm({ if (onSubmitSuccess) { onSubmitSuccess(formData) // Call success callback if provided } - - // --- Mock Error Handling (remove in real implementation) --- - // if (formData.email.includes('fail')) { - // throw new Error("Registration failed: Email already exists."); - // } - // --- End Mock Error Handling --- } catch (apiError: unknown) { console.error('Registration API error:', apiError) - // Try to set a user-friendly error message setSubmitError('Registration failed. Please try again.') } finally { setIsLoading(false) } - // --- End API call section --- }, [formData, validateForm, onSubmitSuccess], ) diff --git a/apps/browser/src/pages/Authorization/LoginPage.tsx b/apps/browser/src/pages/Authorization/LoginPage.tsx index b7961ea..a9b1f60 100644 --- a/apps/browser/src/pages/Authorization/LoginPage.tsx +++ b/apps/browser/src/pages/Authorization/LoginPage.tsx @@ -1,4 +1,8 @@ import React from 'react' +import { fw } from '@entityseven/rage-fw-browser' + +import { AuthEvent } from '../../../../shared/events' + import Input from '../../components/ui/Input' import Checkbox from '../../components/ui/Checkbox' import Button from '../../components/ui/Button' @@ -6,10 +10,17 @@ import { useLoginForm } from '../../hooks/useLoginForm' import { LoginFormData } from '../../validation' const LoginPage: React.FC = () => { - const handleLoginSuccess = (data: LoginFormData) => { - console.log('Login success callback triggered:', data) - // Redirect user or update app state - alert(`Login successful for ${data.identifier}!`) + const handleLoginSuccess = async (data: LoginFormData) => { + const tempData = { + login: data.identifier, + password: data.password, + } + + const response = await fw.event.triggerServer(AuthEvent.LOGIN, [ + tempData, + ]) + + console.log(response) } const { @@ -56,13 +67,13 @@ const LoginPage: React.FC = () => {
{ - const handleRegistrationSuccess = (data: RegisterFormData) => { - console.log('Registration success callback triggered:', data) - // Maybe show a success message or redirect - alert(`Registration successful for ${data.username}!`) + const handleRegistrationSuccess = async (data: RegisterFormData) => { + const tempData = { + login: data.username, + password: data.password, + email: data.email, + } + + const response = await fw.event.triggerServer(AuthEvent.REGISTER, [ + tempData, + ]) + + console.log(response) } const { diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts index 32bef0f..836fb49 100644 --- a/apps/client/src/index.ts +++ b/apps/client/src/index.ts @@ -1,3 +1,3 @@ import { fw } from '@entityseven/rage-fw-client' -fw.player.browser = mp.browsers.new('https://localhost:5173') +fw.player.browser = mp.browsers.new('package://cef/index.html') diff --git a/apps/server/.env b/apps/server/.env new file mode 100644 index 0000000..10a53e9 --- /dev/null +++ b/apps/server/.env @@ -0,0 +1,5 @@ +POSTGRES_USER="postgres" +POSTGRES_PASSWORD="mypassword" +POSTGRES_DB="postgres" + +DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}" \ No newline at end of file diff --git a/apps/server/docker-compose.yml b/apps/server/docker-compose.yml new file mode 100644 index 0000000..cb398d3 --- /dev/null +++ b/apps/server/docker-compose.yml @@ -0,0 +1,20 @@ +services: + database: + image: postgres:17 + ports: + - "5432:5432" + healthcheck: + test: + [ "CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}" ] + interval: 5s + timeout: 10s + retries: 5 + environment: + - POSTGRES_PASSWORD + - POSTGRES_USER + - POSTGRES_DB + volumes: + - rage_fw_db_data:/var/lib/postgresql/data + +volumes: + rage_fw_db_data: \ No newline at end of file diff --git a/apps/server/drizzle.config.ts b/apps/server/drizzle.config.ts new file mode 100644 index 0000000..94ce560 --- /dev/null +++ b/apps/server/drizzle.config.ts @@ -0,0 +1,15 @@ +import 'dotenv/config' +import { defineConfig } from 'drizzle-kit' + +export default defineConfig({ + out: './drizzle', + schema: './src/db/schema.ts', + dialect: 'postgresql', + dbCredentials: { + user: process.env.POSTGRES_USER!, + password: process.env.POSTGRES_PASSWORD!, + database: process.env.POSTGRES_DB!, + host: 'localhost', + ssl: false, + }, +}) diff --git a/apps/server/drizzle/0000_burly_jubilee.sql b/apps/server/drizzle/0000_burly_jubilee.sql new file mode 100644 index 0000000..bad4b2c --- /dev/null +++ b/apps/server/drizzle/0000_burly_jubilee.sql @@ -0,0 +1,10 @@ +CREATE TABLE "users" ( + "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "users_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), + "socialClub" varchar(255) NOT NULL, + "email" varchar(255) NOT NULL, + "login" varchar(255) NOT NULL, + "password" varchar(255) NOT NULL, + CONSTRAINT "users_socialClub_unique" UNIQUE("socialClub"), + CONSTRAINT "users_email_unique" UNIQUE("email"), + CONSTRAINT "users_login_unique" UNIQUE("login") +); diff --git a/apps/server/drizzle/meta/0000_snapshot.json b/apps/server/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..bcedac1 --- /dev/null +++ b/apps/server/drizzle/meta/0000_snapshot.json @@ -0,0 +1,95 @@ +{ + "id": "690592ed-01d9-40ee-91c5-45e2ed38926b", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "users_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "socialClub": { + "name": "socialClub", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "login": { + "name": "login", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_socialClub_unique": { + "name": "users_socialClub_unique", + "nullsNotDistinct": false, + "columns": [ + "socialClub" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "users_login_unique": { + "name": "users_login_unique", + "nullsNotDistinct": false, + "columns": [ + "login" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/server/drizzle/meta/_journal.json b/apps/server/drizzle/meta/_journal.json new file mode 100644 index 0000000..82e38f7 --- /dev/null +++ b/apps/server/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1744901803714, + "tag": "0000_burly_jubilee", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/apps/server/package.json b/apps/server/package.json index a7e1f52..da03690 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -5,9 +5,19 @@ "license": "CC BY-ND", "description": "Server side of rage-fw example", "scripts": { - "build": "esbuild src/index.ts --bundle --platform=node --target=node14.10 --external:*.node --format=cjs --outfile=../../server/packages/server/index.js" + "build": "esbuild src/index.ts --bundle --platform=node --target=node14.10 --format=cjs --outfile=../../server/packages/server/index.js" }, "dependencies": { - "@entityseven/rage-fw-server": "latest" + "@entityseven/rage-fw-server": "latest", + "dotenv": "^16.5.0", + "drizzle-orm": "^0.42.0", + "md5": "^2.3.0", + "pg": "^8.14.1" + }, + "devDependencies": { + "@types/pg": "^8.11.13", + "drizzle-kit": "^0.31.0", + "tsx": "^4.19.3", + "@types/md5": "^2.3.5" } } diff --git a/apps/server/src/db/index.ts b/apps/server/src/db/index.ts new file mode 100644 index 0000000..b5634d1 --- /dev/null +++ b/apps/server/src/db/index.ts @@ -0,0 +1,6 @@ +import 'dotenv/config' +import { drizzle } from 'drizzle-orm/node-postgres' + +const connUrl = `postgres://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASSWORD}@localhost:5432/${process.env.POSTGRES_DB}` + +export const db = drizzle(connUrl) diff --git a/apps/server/src/db/schema.ts b/apps/server/src/db/schema.ts new file mode 100644 index 0000000..18a1ab1 --- /dev/null +++ b/apps/server/src/db/schema.ts @@ -0,0 +1,9 @@ +import { integer, pgTable, varchar } from 'drizzle-orm/pg-core' + +export const usersTable = pgTable('users', { + id: integer().primaryKey().generatedAlwaysAsIdentity(), + socialClub: varchar({ length: 255 }).notNull().unique(), + email: varchar({ length: 255 }).notNull().unique(), + login: varchar({ length: 255 }).notNull().unique(), + password: varchar({ length: 255 }).notNull(), +}) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 8c92f16..ccd66b2 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -1,3 +1,85 @@ -import { checkLicense, doSensitiveOperation } from './x86_64-pc-windows-msvc' +import { fw } from '@entityseven/rage-fw-server' +import { AuthEvent } from '@shared/events' -console.log(doSensitiveOperation('test')) +import md5 from 'md5' + +import { eq, or } from 'drizzle-orm' + +import { usersTable } from './db/schema' +import { db } from './db' + +fw.event.register(AuthEvent.REGISTER, async (player, [data]) => { + const { login, email, password } = data + + const normalizedEmail = email.toLowerCase() + const normalizedLogin = login.toLowerCase() + + try { + const existingUser = await db + .select() + .from(usersTable) + .where( + or( + eq(usersTable.login, normalizedLogin), + eq(usersTable.email, normalizedEmail), + eq(usersTable.socialClub, player.socialClub), + ), + ) + + if (existingUser.length > 0) { + return 'User already exists' + } + + const user: typeof usersTable.$inferInsert = { + socialClub: player.socialClub, + password: md5(password), // we can use md5 for simplicity, but in production you should use more secure hashing algorithms + email: normalizedEmail, + login: normalizedLogin, + } + + await db.insert(usersTable).values(user) + } catch (e) { + console.log(e) + return 'Something went wrong' + } + + console.log('User registered:', player.socialClub) + + return 'User created successfully' +}) + +fw.event.register(AuthEvent.LOGIN, async (player, [data]) => { + const { login, password } = data + const normalizedLogin = login.toLowerCase() + + console.log('Login data', data) + + try { + const users = await db + .select() + .from(usersTable) + .where(eq(usersTable.login, normalizedLogin)) + + if (users.length === 0) { + return 'Invalid credentials' + } + + const user = users[0] + + if (user.password !== md5(password)) { + return 'Invalid credentials' + } + + if (user.socialClub !== player.socialClub) { + return 'Invalid credentials' + } + + console.log('User logged in:', user, player.socialClub) + + // Auth success + return 'Login successful' + } catch (e) { + console.error('Login error:', e) + return 'Internal server error' + } +}) diff --git a/apps/server/src/x86_64-pc-windows-msvc/gta5.win32-x64-msvc.node b/apps/server/src/x86_64-pc-windows-msvc/gta5.win32-x64-msvc.node deleted file mode 100644 index 0d2d43d..0000000 Binary files a/apps/server/src/x86_64-pc-windows-msvc/gta5.win32-x64-msvc.node and /dev/null differ diff --git a/apps/server/src/x86_64-pc-windows-msvc/index.d.ts b/apps/server/src/x86_64-pc-windows-msvc/index.d.ts deleted file mode 100644 index 49d915a..0000000 --- a/apps/server/src/x86_64-pc-windows-msvc/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -/** - * # checkLicense - * Accepts a 16-character license key string. - * Gets the server's local IPv4 address, prints it to the console, - * and validates the key. If valid, unlocks other functions. - * - * Returns `true` if the license key is valid, `false` otherwise. - */ -export declare function checkLicense(licenseKey: string): boolean -/** - * # doSensitiveOperation - * An example function that should only run if the license is validated. - * Takes a name as input and returns a greeting string. - */ -export declare function doSensitiveOperation(name: string): string -/** - * # getSecretData - * Another example function that should only run if the license is validated. - * Returns a dummy secret number. - */ -export declare function getSecretData(): number -/** - * # isLicensed (Optional utility) - * Allows JavaScript to check the current license status without triggering exit. - */ -export declare function isLicensed(): boolean diff --git a/apps/server/src/x86_64-pc-windows-msvc/index.js b/apps/server/src/x86_64-pc-windows-msvc/index.js deleted file mode 100644 index 931197d..0000000 --- a/apps/server/src/x86_64-pc-windows-msvc/index.js +++ /dev/null @@ -1,318 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/* prettier-ignore */ - -/* auto-generated by NAPI-RS */ - -const { existsSync, readFileSync } = require('fs') -const { join } = require('path') - -const { platform, arch } = process - -let nativeBinding = null -let localFileExisted = false -let loadError = null - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== 'function') { - try { - const lddPath = require('child_process').execSync('which ldd').toString().trim() - return readFileSync(lddPath, 'utf8').includes('musl') - } catch (e) { - return true - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header - return !glibcVersionRuntime - } -} - -switch (platform) { - case 'android': - switch (arch) { - case 'arm64': - localFileExisted = existsSync(join(__dirname, 'gta5.android-arm64.node')) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.android-arm64.node') - } else { - nativeBinding = require('gta5-android-arm64') - } - } catch (e) { - loadError = e - } - break - case 'arm': - localFileExisted = existsSync(join(__dirname, 'gta5.android-arm-eabi.node')) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.android-arm-eabi.node') - } else { - nativeBinding = require('gta5-android-arm-eabi') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on Android ${arch}`) - } - break - case 'win32': - switch (arch) { - case 'x64': - localFileExisted = existsSync( - join(__dirname, 'gta5.win32-x64-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.win32-x64-msvc.node') - } else { - nativeBinding = require('gta5-win32-x64-msvc') - } - } catch (e) { - loadError = e - } - break - case 'ia32': - localFileExisted = existsSync( - join(__dirname, 'gta5.win32-ia32-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.win32-ia32-msvc.node') - } else { - nativeBinding = require('gta5-win32-ia32-msvc') - } - } catch (e) { - loadError = e - } - break - case 'arm64': - localFileExisted = existsSync( - join(__dirname, 'gta5.win32-arm64-msvc.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.win32-arm64-msvc.node') - } else { - nativeBinding = require('gta5-win32-arm64-msvc') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`) - } - break - case 'darwin': - localFileExisted = existsSync(join(__dirname, 'gta5.darwin-universal.node')) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.darwin-universal.node') - } else { - nativeBinding = require('gta5-darwin-universal') - } - break - } catch {} - switch (arch) { - case 'x64': - localFileExisted = existsSync(join(__dirname, 'gta5.darwin-x64.node')) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.darwin-x64.node') - } else { - nativeBinding = require('gta5-darwin-x64') - } - } catch (e) { - loadError = e - } - break - case 'arm64': - localFileExisted = existsSync( - join(__dirname, 'gta5.darwin-arm64.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.darwin-arm64.node') - } else { - nativeBinding = require('gta5-darwin-arm64') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`) - } - break - case 'freebsd': - if (arch !== 'x64') { - throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) - } - localFileExisted = existsSync(join(__dirname, 'gta5.freebsd-x64.node')) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.freebsd-x64.node') - } else { - nativeBinding = require('gta5-freebsd-x64') - } - } catch (e) { - loadError = e - } - break - case 'linux': - switch (arch) { - case 'x64': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-x64-musl.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-x64-musl.node') - } else { - nativeBinding = require('gta5-linux-x64-musl') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-x64-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-x64-gnu.node') - } else { - nativeBinding = require('gta5-linux-x64-gnu') - } - } catch (e) { - loadError = e - } - } - break - case 'arm64': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-arm64-musl.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-arm64-musl.node') - } else { - nativeBinding = require('gta5-linux-arm64-musl') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-arm64-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-arm64-gnu.node') - } else { - nativeBinding = require('gta5-linux-arm64-gnu') - } - } catch (e) { - loadError = e - } - } - break - case 'arm': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-arm-musleabihf.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-arm-musleabihf.node') - } else { - nativeBinding = require('gta5-linux-arm-musleabihf') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-arm-gnueabihf.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-arm-gnueabihf.node') - } else { - nativeBinding = require('gta5-linux-arm-gnueabihf') - } - } catch (e) { - loadError = e - } - } - break - case 'riscv64': - if (isMusl()) { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-riscv64-musl.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-riscv64-musl.node') - } else { - nativeBinding = require('gta5-linux-riscv64-musl') - } - } catch (e) { - loadError = e - } - } else { - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-riscv64-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-riscv64-gnu.node') - } else { - nativeBinding = require('gta5-linux-riscv64-gnu') - } - } catch (e) { - loadError = e - } - } - break - case 's390x': - localFileExisted = existsSync( - join(__dirname, 'gta5.linux-s390x-gnu.node') - ) - try { - if (localFileExisted) { - nativeBinding = require('./gta5.linux-s390x-gnu.node') - } else { - nativeBinding = require('gta5-linux-s390x-gnu') - } - } catch (e) { - loadError = e - } - break - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`) - } - break - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) -} - -if (!nativeBinding) { - if (loadError) { - throw loadError - } - throw new Error(`Failed to load native binding`) -} - -const { checkLicense, doSensitiveOperation, getSecretData, isLicensed } = nativeBinding - -module.exports.checkLicense = checkLicense -module.exports.doSensitiveOperation = doSensitiveOperation -module.exports.getSecretData = getSecretData -module.exports.isLicensed = isLicensed diff --git a/apps/shared/declarations/rage-fw-shared-types/index.d.ts b/apps/shared/declarations/rage-fw-shared-types/index.d.ts index 71c52e1..674e8ad 100644 --- a/apps/shared/declarations/rage-fw-shared-types/index.d.ts +++ b/apps/shared/declarations/rage-fw-shared-types/index.d.ts @@ -1,10 +1,17 @@ +import { AuthEvent } from '../../events' + declare module '@entityseven/rage-fw-shared-types' { export interface RageFW_ICustomClientEvent { customClientEvent(greetings: string): string } export interface RageFW_ICustomServerEvent { - customServerEvent(greetings: string): string + [AuthEvent.LOGIN](data: { login: string; password: string }): string + [AuthEvent.REGISTER](data: { + login: string + email: string + password: string + }): string } export interface RageFW_ICustomBrowserEvent { diff --git a/apps/shared/events/index.ts b/apps/shared/events/index.ts new file mode 100644 index 0000000..aae29d6 --- /dev/null +++ b/apps/shared/events/index.ts @@ -0,0 +1,4 @@ +export enum AuthEvent { + LOGIN = 'AuthEvent::LOGIN', + REGISTER = 'AuthEvent::REGISTER', +} diff --git a/apps/shared/package.json b/apps/shared/package.json new file mode 100644 index 0000000..983137a --- /dev/null +++ b/apps/shared/package.json @@ -0,0 +1,7 @@ +{ + "name": "@shared", + "version": "0.1.0", + "author": "Entity Seven Group", + "license": "CC BY-ND", + "description": "Shared types for rage-fw example" +} diff --git a/package.json b/package.json index b1846c9..8840356 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "name": "framework-example", "description": "This project is example of RAGE FW usage.", - "workspaces": ["apps/*"], + "workspaces": [ + "apps/*" + ], "scripts": { "server:update": "cd server && rage-win64.exe", "build:client": "cd apps/client && pnpm build", @@ -20,5 +22,6 @@ }, "author": "Entity Seven Group", "license": "MIT", - "version": "0.1.0" + "version": "0.1.0", + "packageManager": "pnpm@10.2.1+sha512.398035c7bd696d0ba0b10a688ed558285329d27ea994804a52bad9167d8e3a72bcb993f9699585d3ca25779ac64949ef422757a6c31102c12ab932e5cbe5cc92" } diff --git a/server/.env b/server/.env new file mode 100644 index 0000000..10a53e9 --- /dev/null +++ b/server/.env @@ -0,0 +1,5 @@ +POSTGRES_USER="postgres" +POSTGRES_PASSWORD="mypassword" +POSTGRES_DB="postgres" + +DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}" \ No newline at end of file diff --git a/server/release.wasm b/server/release.wasm deleted file mode 100644 index 91b0034..0000000 Binary files a/server/release.wasm and /dev/null differ