[CORL 133] API Review (#2197)

* refactor: removed unused subscription code

* refactor: removed management api's

* refactor: cleanup of connections

* refactor: refactored comments edge

* refactor: simplified connection resolving

* feat: added story connection edge

* fix: added story index

* feat: added user pagination and user edge

* fix: added filter to comment query

* fix: removed unused resolvers

* fix: creating a comment reply should require auth

* refactor: cleanup of graph files

* feat: removed display name, made username non-unique

* fix: fixed tests

* fix: fixed tests

* fix: added more api docs

* fix: fixed bug with installer

* refactor: fixes and updates

* fix: added linting for graphql, fixed schema

* feat: added docker build tests

* fix: upped output timeout

* fix: fixed stacktraces in production builds

* fix: removed `git add`

- `git add` was causing issues with
    partial staged changs on files

* feat: improved error messaging for auth

* refactor: cleaned up queue names

* fix: merge error
This commit is contained in:
Wyatt Johnson
2019-03-12 15:12:21 +01:00
committed by Kiwi
parent 37959f9398
commit d37333be89
125 changed files with 1269 additions and 1536 deletions
+36 -18
View File
@@ -16,12 +16,7 @@ export type AugmentedRedis = Omit<Redis, "pipeline"> &
pipeline(commands?: string[][]): AugmentedPipeline;
};
function configureRedisClient(redis: Redis) {
// Attach to the error event.
redis.on("error", (err: Error) => {
logger.error({ err }, "an error occurred with redis");
});
function augmentRedisClient(redis: Redis): AugmentedRedis {
// mhincrby will increment many hash values.
redis.defineCommand("mhincrby", {
numberOfKeys: 1,
@@ -31,28 +26,51 @@ function configureRedisClient(redis: Redis) {
end
`,
});
return redis as AugmentedRedis;
}
/**
* create will connect to the Redis instance identified in the configuration.
*
* @param config application configuration.
*/
export async function createRedisClient(
config: Config
): Promise<AugmentedRedis> {
function attachHandlers(redis: Redis) {
// Attach to the error event.
redis.on("error", (err: Error) => {
logger.error({ err }, "an error occurred with redis");
});
}
export function createRedisClient(
config: Config,
lazyConnect: boolean = false
): Redis {
try {
const redis = new RedisClient(config.get("redis"), {
lazyConnect: true,
lazyConnect,
});
// Configure the redis client for use with the custom commands.
configureRedisClient(redis);
// Configure the redis client with the handlers for logging
attachHandlers(redis);
return redis;
} catch (err) {
throw new InternalError(err, "could not connect to redis");
}
}
/**
* createAugmentedRedisClient will connect to the Redis instance identified in
* the configuration.
*
* @param config application configuration.
*/
export async function createAugmentedRedisClient(
config: Config
): Promise<AugmentedRedis> {
try {
const redis = augmentRedisClient(createRedisClient(config, true));
// Connect the redis client.
await redis.connect();
return redis as AugmentedRedis;
return redis;
} catch (err) {
throw new InternalError(err, "could not connect to redis");
}