This commit is contained in:
Oleksandr Honcharov 2024-06-09 01:35:14 +03:00
commit d67073d739
11 changed files with 1435 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea
node_modules

7
.prettierrc.yaml Normal file
View File

@ -0,0 +1,7 @@
tabWidth: 4
printWidth: 80
singleQuote: true
jsxSingleQuote: false
semi: false
arrowParens: avoid
endOfLine: auto

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"private": true,
"workspaces": [
"server"
],
"dependencies": {
"@ragempcommunity/types-client": "^2.1.8",
"@ragempcommunity/types-server": "^2.1.8",
"@ragempcommunity/types-cef": "^2.1.8",
"rage-rpc": "^0.4.0",
"tsup": "^8.1.0",
"prettier": "^3.3.1",
"typescript": "^5.4.5"
},
"type": "module"
}

1315
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

14
server/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "rage-f-server",
"version": "0.0.1",
"main": "dist/index.js",
"type": "module",
"files": ["dist/**/*"],
"scripts": {
"build": "tsup"
},
"keywords": [],
"author": "SashaGonncharov19",
"license": "MIT",
"description": "Server side of rage-f"
}

36
server/src/index.ts Normal file
View File

@ -0,0 +1,36 @@
/// <reference types="@ragempcommunity/types-server" />
import rpc from 'rage-rpc'
type ServerEvent<K> = K extends keyof IServerEvents ? K : never
type ServerEventCallback<K> = K extends keyof IServerEvents
? ThisifyServerEvents[K]
: never
declare class Server {
public register<K = ServerEvent<K>>(
eventName: K,
callback: ServerEventCallback,
): void
public registerMultiple(events: {
[name: string]: (player: PlayerMp, ...args: any[]) => any
}): void
registerMultiple(events: { [name: string]: (...args: any[]) => any }) {
Object.entries(events).forEach(([name, callback]) =>
rpc.register(name, (data: any[]) => {
return Array.isArray(data) ? callback(...data) : callback(data)
}),
)
}
register() {}
}
export const rage = {
event: new Server(),
}
rage.event.register('customevent', vehicle => {})
function test() {}

12
server/tsconfig.json Normal file
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "ES5"],
"module": "ESNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"types": ["../node_modules/@ragempcommunity/types-server"]
}
}

13
shared/package.json Normal file
View File

@ -0,0 +1,13 @@
{
"name": "rage-f-shared",
"version": "0.0.1",
"main": "dist/index.js",
"type": "module",
"scripts": {
"test": "tsup"
},
"keywords": [],
"author": "SashaGonncharov19",
"license": "MIT",
"description": "Server side of rage-f"
}

0
shared/src/index.ts Normal file
View File

10
shared/tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}