mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
bf45e97641
* Update types * fix circular dep * type imports * lint type imports and --fix
30 lines
619 B
TypeScript
30 lines
619 B
TypeScript
import type { Transaction } from "sequelize";
|
|
import type { User } from "@server/models";
|
|
import type { APIContext } from "@server/types";
|
|
import { AuthenticationType } from "@server/types";
|
|
|
|
export function createContext({
|
|
user,
|
|
authType = AuthenticationType.APP,
|
|
ip,
|
|
transaction,
|
|
}: {
|
|
user?: User;
|
|
authType?: AuthenticationType | null;
|
|
ip?: string | null;
|
|
transaction?: Transaction;
|
|
}) {
|
|
const auth = { user, type: authType };
|
|
return {
|
|
state: {
|
|
auth,
|
|
transaction,
|
|
},
|
|
context: {
|
|
auth,
|
|
ip: ip ?? user?.lastActiveIp,
|
|
transaction,
|
|
},
|
|
} as APIContext;
|
|
}
|