feat: support development url's

This commit is contained in:
Wyatt Johnson
2018-10-29 14:31:35 -06:00
parent 6fc2eabc88
commit 2571f048ad
8 changed files with 26 additions and 12 deletions
+5 -1
View File
@@ -1,17 +1,21 @@
import { Config } from "talk-common/config";
import { User } from "talk-server/models/user";
import { Request } from "talk-server/types/express";
export interface CommonContextOptions {
user?: User;
req?: Request;
config: Config;
}
export default class CommonContext {
public user?: User;
public req?: Request;
public config: Config;
constructor({ user, req }: CommonContextOptions) {
constructor({ user, req, config }: CommonContextOptions) {
this.user = user;
this.req = req;
this.config = config;
}
}
+4 -2
View File
@@ -1,18 +1,20 @@
import { Db } from "mongodb";
import { Config } from "talk-common/config";
import CommonContext from "talk-server/graph/common/context";
import { Request } from "talk-server/types/express";
export interface ManagementContextOptions {
mongo: Db;
config: Config;
req?: Request;
}
export default class ManagementContext extends CommonContext {
public mongo: Db;
constructor({ req, mongo }: ManagementContextOptions) {
super({ req });
constructor({ req, mongo, config }: ManagementContextOptions) {
super({ req, config });
this.mongo = mongo;
}
@@ -10,5 +10,5 @@ import ManagementContext from "./context";
export default (schema: GraphQLSchema, config: Config, mongo: Db) =>
graphqlMiddleware(config, async (req: Request) => ({
schema,
context: new ManagementContext({ req, mongo }),
context: new ManagementContext({ req, mongo, config }),
}));
+4 -1
View File
@@ -8,6 +8,7 @@ import { TaskQueue } from "talk-server/services/queue";
import TenantCache from "talk-server/services/tenant/cache";
import { Request } from "talk-server/types/express";
import { Config } from "talk-common/config";
import loaders from "./loaders";
import mutators from "./mutators";
@@ -17,6 +18,7 @@ export interface TenantContextOptions {
tenant: Tenant;
tenantCache: TenantCache;
queue: TaskQueue;
config: Config;
req?: Request;
user?: User;
}
@@ -37,10 +39,11 @@ export default class TenantContext extends CommonContext {
tenant,
mongo,
redis,
config,
tenantCache,
queue,
}: TenantContextOptions) {
super({ user, req });
super({ user, req, config });
this.tenant = tenant;
this.tenantCache = tenantCache;
@@ -19,7 +19,7 @@ const OIDCAuthIntegration: GQLOIDCAuthIntegrationTypeResolver<
// Note that when constructing the callback url with the tenant, the port
// information is lost.
return reconstructTenantURL(ctx.tenant, path);
return reconstructTenantURL(ctx.config, ctx.tenant, path);
},
};