get mongo running
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
Server,
|
||||
ServerUnaryCall,
|
||||
sendUnaryData,
|
||||
loadPackageDefinition,
|
||||
} from '@grpc/grpc-js'
|
||||
import { Server } from '@grpc/grpc-js'
|
||||
import { ReflectionService } from '@grpc/reflection'
|
||||
import { loadSync } from '@grpc/proto-loader'
|
||||
|
||||
@@ -13,45 +8,33 @@ import {
|
||||
CreateCharacterRequest,
|
||||
} from './proto/character'
|
||||
|
||||
import { characterManagerDefinition } from './proto/character.grpc-server'
|
||||
import {
|
||||
characterManagerDefinition,
|
||||
ICharacterManager,
|
||||
} from './proto/character.grpc-server'
|
||||
|
||||
export function initCharacterService(server: Server) {
|
||||
server.addService(characterManagerDefinition, {
|
||||
createCharacter: createCharacter_Call,
|
||||
getCharacter: getCharacter_Call,
|
||||
})
|
||||
server.addService(characterManagerDefinition, CharacterManagerService)
|
||||
|
||||
new ReflectionService(loadSync('./src/proto/character.proto')).addToServer(
|
||||
server,
|
||||
)
|
||||
}
|
||||
|
||||
function createCharacter_Call(
|
||||
call: ServerUnaryCall<CreateCharacterRequest, Character>,
|
||||
callback: sendUnaryData<Character>,
|
||||
) {
|
||||
callback(null, createCharacter(call.request))
|
||||
}
|
||||
const CharacterManagerService: ICharacterManager = {
|
||||
createCharacter: (request: CreateCharacterRequest): Character => {
|
||||
return {
|
||||
playerName: 'test player',
|
||||
characterName: 'test character',
|
||||
characterAlias: ['test alias'],
|
||||
}
|
||||
},
|
||||
|
||||
function createCharacter(request: CreateCharacterRequest): Character {
|
||||
return {
|
||||
playerName: 'test player',
|
||||
characterName: 'test character',
|
||||
characterAlias: ['test alias'],
|
||||
}
|
||||
}
|
||||
|
||||
function getCharacter_Call(
|
||||
call: ServerUnaryCall<GetCharacterRequest, Character>,
|
||||
callback: sendUnaryData<Character>,
|
||||
) {
|
||||
callback(null, getCharacter(call.request))
|
||||
}
|
||||
|
||||
function getCharacter(request: GetCharacterRequest): Character {
|
||||
return {
|
||||
playerName: 'test player',
|
||||
characterName: 'test character',
|
||||
characterAlias: ['test alias'],
|
||||
}
|
||||
getCharacter: (request: GetCharacterRequest): Character => {
|
||||
return {
|
||||
playerName: 'test player',
|
||||
characterName: 'test character',
|
||||
characterAlias: ['test alias'],
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user