-
Notifications
You must be signed in to change notification settings - Fork 25
Typescript module server #936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/federated
Are you sure you want to change the base?
Conversation
* prelude update * docker version --------- Co-authored-by: Mitchell Shiell <[email protected]>
import { Client, type ClientOptions } from '@elastic/elasticsearch'; | ||
|
||
export const buildEsClient = (esHost = '', esUser = '', esPass = '') => { | ||
if (!esHost) { | ||
console.error('no elasticsearch host was provided'); | ||
} | ||
|
||
const esConfig: ClientOptions = { | ||
node: esHost, | ||
}; | ||
|
||
if (esUser) { | ||
if (!esPass) { | ||
console.error('ES user was defined, but password was not'); | ||
} | ||
esConfig['auth'] = { | ||
username: esUser, | ||
password: esPass, | ||
}; | ||
} | ||
|
||
return new Client(esConfig); | ||
}; | ||
|
||
export const buildEsClientViaEnv = (ES_HOST: string, ES_USER: string, ES_PASS: string) => { | ||
return buildEsClient(ES_HOST, ES_USER, ES_PASS); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move ES client to module
import { Client, type ClientOptions } from '@elastic/elasticsearch'; | ||
|
||
export const buildEsClient = (esHost = '', esUser = '', esPass = '') => { | ||
if (!esHost) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it be fair to provide a default value for this?
ES has a common 9200 port, and localhost is a usual
import type { Client } from '@elastic/elasticsearch'; | ||
import type { SQONFilter } from '#sqon/index.js'; | ||
import { getCaughtErrorMessage } from '#utils/caughtError.js'; | ||
import type { GraphQLSchema } from 'graphql'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, would you add these in the order/position that keeps consistency with code already present?
I've found that using this Microsoft extension for ESLint helps a lot keeping track of this and other "consistency" items https://marketplace.visualstudio.com/items/?itemName=dbaeumer.vscode-eslint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handy extension thank you 👍 they become "out of sync" with VSCode "import this file" which we now have after ts-ify 👍
@@ -294,15 +307,26 @@ export const createSchemasFromConfigs = async ({ | |||
schema: fullSchema, | |||
}; | |||
} catch (error) { | |||
const message = error?.message || error; | |||
const message = getCaughtErrorMessage(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 one more from my ToDo:s, thanks for handling it!
type
is correctly in imports(_req, res)...
getCaughtErrorMessage
any
for nowFurther improvements: