Add GetNEXData GRPC method

Returns all details of a NEX account.
This commit is contained in:
Daniel López Guimaraes 2023-07-17 00:20:26 +01:00
parent 06c9cc9c01
commit 3844531191
No known key found for this signature in database
GPG Key ID: 6AC74DE3DEF050E0
3 changed files with 30 additions and 10 deletions

10
package-lock.json generated
View File

@ -1175,11 +1175,6 @@
"node": ">=0.8"
}
},
"node_modules/async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -4384,12 +4379,11 @@
}
},
"node_modules/pretendo-grpc-ts": {
"version": "1.0.1",
"resolved": "git+ssh://git@github.com/PretendoNetwork/grpc-ts.git#64c83180d1f2d0829fd8d5e0e6305c6c019b1f03",
"version": "1.0.3",
"resolved": "git+ssh://git@github.com/PretendoNetwork/grpc-ts.git#8047b4d49c9a27cc7edd3786b465c3b0939b6181",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
"async": "^3.2.4",
"long": "^5.2.1",
"protobufjs": "^7.2.3"
}

View File

@ -0,0 +1,24 @@
import { Status, ServerError } from 'nice-grpc';
import {GetNEXDataRequest,GetNEXDataResponse, DeepPartial } from 'pretendo-grpc-ts/dist/account/get_nex_data_rpc';
import { NEXAccount } from '@/models/nex-account';
import { HydratedNEXAccountDocument } from '@/types/mongoose/nex-account';
export async function getNEXData(request: GetNEXDataRequest): Promise<DeepPartial<GetNEXDataResponse>> {
const nexAccount: HydratedNEXAccountDocument | null = await NEXAccount.findOne({ pid: request.pid });
if (!nexAccount) {
throw new ServerError(
Status.INVALID_ARGUMENT,
'No NEX account found found',
);
}
return {
pid: nexAccount.pid,
password: nexAccount.password,
owningPid: nexAccount.owning_pid,
accessLevel: nexAccount.access_level,
serverAccessLevel: nexAccount.server_access_level,
friendCode: nexAccount.friend_code
};
}

View File

@ -1,8 +1,10 @@
import { AccountServiceImplementation } from 'pretendo-grpc-ts/dist/account/account_service';
import { getUserData } from '@/services/grpc/account/get-user-data';
import { getNEXPassword } from '@/services/grpc/account/get-nex-password';
import { getNEXData } from '@/services/grpc/account/get-nex-data';
export const accountServiceImplementation: AccountServiceImplementation = {
getUserData,
getNEXPassword
};
getNEXPassword,
getNEXData
};