When using the javascript prisma-client i cannot f...
# orm-help
y
When using the javascript prisma-client i cannot figure out how to set the PRISMA_PORT? Seems to be hardcoded. in ts I can do (my own code)
Copy code
const db = new Prisma({
  endpoint: `http://${process.env.PRISMA_SERVICE_NAME}:${
    process.env.PRISMA_PORT
  }`,
  secret: process.env.PRISMA_SECRET,
})
but in the generated javascript client this seems to be hardcoded:
Copy code
exports.Prisma = prisma_lib_1.makePrismaClientClass({
  typeDefs,
  models,
  endpoint: `<http://localhost:${process.env[%22PRISMA_PORT%22]}|http://localhost:${process.env["PRISMA_PORT"]}>`,
  secret: `${process.env["PRISMA_SECRET"]}`
});
exports.prisma = new exports.Prisma();
d
Can you please share your
prisma.yml
file?
y
Copy code
datamodel:
  - enums.prisma
  - types.prisma

seed:
  import: ./seed/seed.graphql

# this can be an environment variable OR the endpoint from the initial prisma init/deploy
endpoint: <http://localhost:${env:PRISMA_PORT}>
hooks:
  post-deploy:
    - prisma generate
# see: <https://www.prisma.io/docs/prisma-graphql-api/reference/authentication-ghd4/>
secret: ${env:PRISMA_SECRET}

generate:
  - generator: typescript-client
    output: build/prisma-client/typescript
  - generator: javascript-client
    output: build/prisma-client/javascript
  # replaces - graphql get-schema --project prisma
  # copy prisma schema to prisma client
  - generator: graphql-schema
    output: build/schema/
d
The
PRISMA_PORT
is coming from the endpoint property in
prisma.yml
file.. it is an environment variable
You can change that and run
prisma generate
again
y
I know that . My question is about whether the prisma port is hardcoded in the prisma javascript client ? It is not hardcoded in the prisma typescript client
... and thank you for looking uinto this 🙂
d
It is not hardcoded even in JS client.
Same process should generate a new JS client.
y
so in my client I should be able to do something like :
Copy code
const db = new Prisma({
  endpoint: `http://${process.env.PRISMA_SERVICE_NAME}:${
    process.env.PRISMA_PORT
  }`,
  secret: process.env.PRISMA_SECRET,
})
do you know where I can find an example? could not see it done this way in prisma-examples