mirror of
https://github.com/outline/outline.git
synced 2026-01-05 18:49:53 -06:00
* createContext accepts object * handle subscriptions * use createContext * should've done this on the initial attempt...
24 lines
504 B
TypeScript
24 lines
504 B
TypeScript
import { Transaction } from "sequelize";
|
|
import { User } from "@server/models";
|
|
import { APIContext, AuthenticationType } from "@server/types";
|
|
|
|
export function createContext({
|
|
user,
|
|
authType = AuthenticationType.APP,
|
|
ip,
|
|
transaction,
|
|
}: {
|
|
user: User;
|
|
authType?: AuthenticationType | null;
|
|
ip?: string | null;
|
|
transaction?: Transaction;
|
|
}) {
|
|
return {
|
|
context: {
|
|
auth: { user, type: authType },
|
|
ip: ip ?? user.lastActiveIp,
|
|
transaction,
|
|
},
|
|
} as APIContext;
|
|
}
|