mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
957ce69d2e
* perf: Move image download out of transaction * loop
33 lines
667 B
TypeScript
33 lines
667 B
TypeScript
import type { Transaction } from "sequelize";
|
|
import type { User } from "@server/models";
|
|
import type { APIContext } from "@server/types";
|
|
import { AuthenticationType } from "@server/types";
|
|
|
|
/**
|
|
* Factory to create a new API context.
|
|
*/
|
|
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;
|
|
}
|