MCPcopy
hub / github.com/graphile/starter / asRoot

Function asRoot

@app/__tests__/helpers.ts:65–82  ·  view source on GitHub ↗
(
  client: PoolClient,
  callback: (client: PoolClient) => Promise<T>
)

Source from the content-addressed store, hash-verified

63
64/* Quickly becomes root, does the thing, and then reverts back to previous role */
65export const asRoot = async <T>(
66 client: PoolClient,
67 callback: (client: PoolClient) => Promise<T>
68): Promise<T> => {
69 const {
70 rows: [{ role }],
71 } = await client.query("select current_setting('role') as role");
72 await client.query("reset role");
73 try {
74 return await callback(client);
75 } finally {
76 try {
77 await client.query("select set_config('role', $1, true)", [role]);
78 } catch (e) {
79 // Transaction was probably aborted, don't clobber the error
80 }
81 }
82};
83
84/******************************************************************************/
85

Callers 10

register.test.tsFile · 0.90
getSessionsFunction · 0.90
clearJobsFunction · 0.90
getJobsFunction · 0.90
runJobsFunction · 0.90
assertJobCompleteFunction · 0.90
addEmailFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected