Skip to content
Snippets Groups Projects
Commit 7a1c905d authored by Gregor Schulz's avatar Gregor Schulz
Browse files

Merge branch 'main' into 'production'

fix userId forwarding on production

See merge request app/holi-notifications!3
parents c1b60d29 596c0655
Branches
Tags
No related merge requests found
...@@ -7,6 +7,3 @@ fi ...@@ -7,6 +7,3 @@ fi
# loads personal (secret) data from separate env file (not checked in) # loads personal (secret) data from separate env file (not checked in)
source_env_if_exists .envrc.local source_env_if_exists .envrc.local
type yarn >/dev/null 2>&1 && PATH="$PATH:$(yarn global bin)"
export PATH
\ No newline at end of file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
gitleaks protect --staged -v -c ../.gitleaks.toml
repos:
- repo: local
hooks:
- id: gitleaks
name: gitleaks
language: system
entry: gitleaks protect --staged -v -c ../.gitleaks.toml
pass_filenames: false
always_run: true
...@@ -10,7 +10,12 @@ In this guide you will get an overview of the contribution workflow from opening ...@@ -10,7 +10,12 @@ In this guide you will get an overview of the contribution workflow from opening
## New Contributor guide ## New Contributor guide
There's many ways you could contribute to holi. For all of them, you first need an account on our gitlab. Set one up [here](https://app.gitlab-pages.holi.team/users/sign_up), after which we will approve your account. You will get confirmation via E-Mail and can proceed with setting up your account by following the instructions in the E-Mail and in GitLab itself. There's many ways you could contribute to holi. For all of them, you first need an account on our gitlab. Set one up
[here](https://gitlab.holi.team/users/sign_up). Your account will then be confirmed by an administrator. This might take
some time. Afterwards, you will receive an E-Mail welcoming you to our GitLab instance. Via a link in this mail, you can
sign in and set up your account by following the instructions in the E-Mail and in GitLab itself.
If you didn't receive a mail, make sure to check your spam folder before contacting us via support@holi.social.
### Finding and reporting bugs ### Finding and reporting bugs
......
export { serve } from "https://deno.land/std@0.155.0/http/server.ts"; export { serve } from "https://deno.land/std@0.155.0/http/server.ts";
export { createSchema, createYoga } from "npm:graphql-yoga@5.1.0"; export {
export { useResponseCache } from "npm:@graphql-yoga/plugin-response-cache@3.2.0"; createSchema,
createYoga,
type YogaInitialContext,
} from "npm:graphql-yoga@5.1.0";
export { Parser } from "https://deno.land/x/html_parser@v0.1.3/src/mod.ts"; export { Parser } from "https://deno.land/x/html_parser@v0.1.3/src/mod.ts";
export { ChannelTypeEnum, Novu } from "npm:@novu/node@0.22.0"; export { ChannelTypeEnum, Novu } from "npm:@novu/node@0.22.0";
export { GraphQLError } from "npm:graphql@16.8.1"; export { GraphQLError } from "npm:graphql@16.8.1";
......
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
createYoga, createYoga,
Novu, Novu,
serve, serve,
useResponseCache, YogaInitialContext,
} from "./deps.ts"; } from "./deps.ts";
import { logger } from "./logging.ts"; import { logger } from "./logging.ts";
import { import {
...@@ -25,16 +25,9 @@ export interface ServerConfig { ...@@ -25,16 +25,9 @@ export interface ServerConfig {
environment: string; environment: string;
} }
export type GraphQLContext = { export type ServiceContext = {
params?: { userId: string;
extensions?: { } & YogaInitialContext;
headers?: {
[key: string]: string;
};
};
};
userId?: string;
};
const typeDefs = ` const typeDefs = `
enum Channel { enum Channel {
...@@ -77,7 +70,7 @@ const createResolvers = (novu: Novu, config: ServerConfig) => { ...@@ -77,7 +70,7 @@ const createResolvers = (novu: Novu, config: ServerConfig) => {
_parent: any, _parent: any,
// deno-lint-ignore no-explicit-any // deno-lint-ignore no-explicit-any
_parameters: any, _parameters: any,
context: GraphQLContext, context: ServiceContext,
): Promise<PreferencesResponse> => { ): Promise<PreferencesResponse> => {
return config.fake return config.fake
? Promise.resolve([]) ? Promise.resolve([])
...@@ -89,7 +82,7 @@ const createResolvers = (novu: Novu, config: ServerConfig) => { ...@@ -89,7 +82,7 @@ const createResolvers = (novu: Novu, config: ServerConfig) => {
// deno-lint-ignore no-explicit-any // deno-lint-ignore no-explicit-any
_parent: any, _parent: any,
parameters: UpdatePreferencesParameters, parameters: UpdatePreferencesParameters,
context: GraphQLContext, context: ServiceContext,
): Promise<PreferencesResponse> => ): Promise<PreferencesResponse> =>
config.fake ? Promise.resolve([]) : updatePreferences( config.fake ? Promise.resolve([]) : updatePreferences(
novu, novu,
...@@ -104,23 +97,16 @@ export const createGraphQLServer = ( ...@@ -104,23 +97,16 @@ export const createGraphQLServer = (
novu: Novu, novu: Novu,
config: ServerConfig, config: ServerConfig,
): GraphQLServer => { ): GraphQLServer => {
const plugins = [
useResponseCache({
// cache by user id
session: (request: Request) => request.headers.get(HEADER_USER_ID),
}),
];
const resolvers = createResolvers(novu, config); const resolvers = createResolvers(novu, config);
return createYoga({ return createYoga({
schema: createSchema({ resolvers, typeDefs }), schema: createSchema({ resolvers, typeDefs }),
graphiql: config.environment === LOCAL_ENVIRONMENT, graphiql: config.environment === LOCAL_ENVIRONMENT,
plugins, context: (context: YogaInitialContext) => {
context: (context: GraphQLContext) => { const headers = new Headers(context.request.headers);
const headers = new Headers(context.params?.extensions?.headers);
return { return {
...context, ...context,
userId: headers.get(HEADER_USER_ID), userId: headers.get(HEADER_USER_ID),
} as GraphQLContext; } as ServiceContext;
}, },
}); });
}; };
......
...@@ -27,7 +27,6 @@ export const processGqlRequest = ( ...@@ -27,7 +27,6 @@ export const processGqlRequest = (
operationName: null, operationName: null,
variables: variables, variables: variables,
query: query, query: query,
extensions: { headers },
}), }),
}); });
return graphQLServer.handleRequest(request) return graphQLServer.handleRequest(request)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment