You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the documentation it describes providing a property in the configuration:
ss: {}
But there is no example of how to user it and what to put into that and any other necessary requirements.
Desired Behavior
I would like to see an example of what parameters are supplied to connect via ssl over slonik to my ssl protected postgress docker container.
Motivation
Implementation
I have created the following crt, key and pem on my windows host.
I have then copied them to the docker container and setup the necessary ssl configuration.
I have created an equivalent pg example and that connects over ssl
pg-server.ts
importdotEnvfrom"dotenv";importpgfrom"pg";importfsfrom"fs";importpathfrom"path";dotEnv.config();const{ env }=process;constPG_DB=env.PG_DBasstring;constPG_USER=env.PG_USERasstring;constPG_PWD=env.PG_PWDasstring;constPG_TABLE=env.PG_TABLEasstring;constpem=fs.readFileSync(path.join(__dirname,"./ssl/server.pem")).toString();constinit=()=>{constclient=newpg.Client({user: PG_USER,password: PG_PWD,database: PG_DB,port: 5432,host: "localhost",ssl: {ca: pem,// Example - equivalent needed for slonik},});client.connect();client.query(`SELECT * FROM ${PG_TABLE} ORDER BY id ASC`,(result)=>{console.log('pg query',result)// Works});};init();
slonik-server.ts
constpool=createPool(`postgresql://${PG_USER}:${PG_PWD}@localhost:5432/${PG_DB}`,{ssl: {ca: pem,rejectUnauthorized: true,}});pool.connect(async(connection)=>{try{constresultExist=awaitconnection.query(sql`SELECT EXISTS (SELECT FROM pg_tables WHERE tablename = ${PG_TABLE});`);constisExist=resultExist.rows[0].exists;console.log('DB exists =',{isExist})// NOTE: Could need to use sql.identifier to reference dynamic table name.constresultRows=awaitconnection.query(sql`SELECT * FROM ${sql.identifier([PG_TABLE])} ORDER BY id ASC`);console.log('TABLE ROWS',{resultRows})}catch(err){console.log(err);}});
Both of these examples work. It would be useful to have a basic example like this in your documentation
The text was updated successfully, but these errors were encountered:
In the documentation it describes providing a property in the configuration:
ss: {}
But there is no example of how to user it and what to put into that and any other necessary requirements.
Desired Behavior
I would like to see an example of what parameters are supplied to connect via ssl over slonik to my ssl protected postgress docker container.
Motivation
Implementation
I have created the following crt, key and pem on my windows host.
I have then copied them to the docker container and setup the necessary ssl configuration.
I have created an equivalent pg example and that connects over ssl
pg-server.ts
slonik-server.ts
Both of these examples work. It would be useful to have a basic example like this in your documentation
The text was updated successfully, but these errors were encountered: