Skip to content

Instantly share code, notes, and snippets.

@theorm
Created October 5, 2019 10:13
Show Gist options
  • Select an option

  • Save theorm/2b6e38ffe9614b78fb6ddd24eb17ab4b to your computer and use it in GitHub Desktop.

Select an option

Save theorm/2b6e38ffe9614b78fb6ddd24eb17ab4b to your computer and use it in GitHub Desktop.
import { loadSync, Options } from '@grpc/proto-loader'
import { PackageDefinition } from 'grpc'
const ProtoBaseDir = process.env.JETSETTER_SCHEMAS_PATH || `${__dirname}/../../../schemas`
const DefaultLoadOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: false,
oneofs: true,
includeDirs: [
'proto/services',
'proto/messages'
].map(p => `${ProtoBaseDir}/${p}`)
} as Options
export function readPackageDefinition(path: string): PackageDefinition {
// console.debug('Load options', JSON.stringify(DefaultLoadOptions))
return loadSync(path, DefaultLoadOptions)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment