mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-26 23:06:37 +00:00
Fix frontend type imports
This commit is contained in:
@@ -4,25 +4,7 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import privateConfig from "@server/private/lib/config";
|
||||
|
||||
export type NewLicenseKey = {
|
||||
licenseKey: {
|
||||
id: number;
|
||||
instanceName: string | null;
|
||||
instanceId: string;
|
||||
licenseKey: string;
|
||||
tier: string;
|
||||
type: string;
|
||||
quantity: number;
|
||||
isValid: boolean;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
expiresAt: string;
|
||||
orgId: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type GenerateNewLicenseResponse = NewLicenseKey;
|
||||
import { GenerateNewLicenseResponse } from "@server/routers/generatedLicense/types";
|
||||
|
||||
async function createNewLicense(orgId: string, licenseData: any): Promise<any> {
|
||||
try {
|
||||
|
||||
@@ -4,18 +4,7 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import privateConfig from "@server/private/lib/config";
|
||||
|
||||
export type GeneratedLicenseKey = {
|
||||
instanceName: string | null;
|
||||
licenseKey: string;
|
||||
expiresAt: string;
|
||||
isValid: boolean;
|
||||
createdAt: string;
|
||||
tier: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type ListGeneratedLicenseKeysResponse = GeneratedLicenseKey[];
|
||||
import { GeneratedLicenseKey, ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types";
|
||||
|
||||
async function fetchLicenseKeys(orgId: string): Promise<any> {
|
||||
try {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { response as sendResponse } from "@server/lib/response";
|
||||
import license from "#private/license/license";
|
||||
import { z } from "zod";
|
||||
import { fromError } from "zod-validation-error";
|
||||
import { LicenseStatus } from "@server/license/license";
|
||||
|
||||
const bodySchema = z
|
||||
.object({
|
||||
@@ -14,8 +13,6 @@ const bodySchema = z
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type ActivateLicenseStatus = LicenseStatus;
|
||||
|
||||
export async function activateLicense(
|
||||
req: Request,
|
||||
res: Response,
|
||||
|
||||
@@ -9,7 +9,6 @@ import { db } from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { licenseKey } from "@server/db";
|
||||
import license from "#private/license/license";
|
||||
import { LicenseStatus } from "@server/license/license";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
@@ -17,8 +16,6 @@ const paramsSchema = z
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type DeleteLicenseKeyResponse = LicenseStatus;
|
||||
|
||||
export async function deleteLicenseKey(
|
||||
req: Request,
|
||||
res: Response,
|
||||
|
||||
@@ -4,9 +4,7 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import license from "#private/license/license";
|
||||
import { LicenseStatus } from "@server/license/license";
|
||||
|
||||
export type GetLicenseStatusResponse = LicenseStatus;
|
||||
import { GetLicenseStatusResponse } from "@server/routers/license/types";
|
||||
|
||||
export async function getLicenseStatus(
|
||||
req: Request,
|
||||
|
||||
@@ -4,9 +4,7 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import license from "#private/license/license";
|
||||
import { LicenseKeyCache } from "@server/license/license";
|
||||
|
||||
export type ListLicenseKeysResponse = LicenseKeyCache[];
|
||||
import { ListLicenseKeysResponse } from "@server/routers/license/types";
|
||||
|
||||
export async function listLicenseKeys(
|
||||
req: Request,
|
||||
|
||||
@@ -4,9 +4,6 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import license from "#private/license/license";
|
||||
import { LicenseStatus } from "@server/license/license";
|
||||
|
||||
export type RecheckStatusResponse = LicenseStatus;
|
||||
|
||||
export async function recheckStatus(
|
||||
req: Request,
|
||||
|
||||
@@ -560,39 +560,6 @@ function allowed(res: Response, userData?: BasicUserData) {
|
||||
return response<VerifyUserResponse>(res, data);
|
||||
}
|
||||
|
||||
async function createAccessTokenSession(
|
||||
res: Response,
|
||||
resource: Resource,
|
||||
tokenItem: ResourceAccessToken
|
||||
) {
|
||||
const token = generateSessionToken();
|
||||
const sess = await createResourceSession({
|
||||
resourceId: resource.resourceId,
|
||||
token,
|
||||
accessTokenId: tokenItem.accessTokenId,
|
||||
sessionLength: tokenItem.sessionLength,
|
||||
expiresAt: tokenItem.expiresAt,
|
||||
doNotExtend: tokenItem.expiresAt ? true : false
|
||||
});
|
||||
const cookieName = `${config.getRawConfig().server.session_cookie_name}`;
|
||||
const cookie = serializeResourceSessionCookie(
|
||||
cookieName,
|
||||
resource.fullDomain!,
|
||||
token,
|
||||
!resource.ssl,
|
||||
new Date(sess.expiresAt)
|
||||
);
|
||||
res.appendHeader("Set-Cookie", cookie);
|
||||
logger.debug("Access token is valid, creating new session");
|
||||
return response<VerifyUserResponse>(res, {
|
||||
data: { valid: true },
|
||||
success: true,
|
||||
error: false,
|
||||
message: "Access allowed",
|
||||
status: HttpCode.OK
|
||||
});
|
||||
}
|
||||
|
||||
async function isUserAllowedToAccessResource(
|
||||
userSessionId: string,
|
||||
resource: Resource
|
||||
|
||||
30
server/routers/generatedLicense/types.ts
Normal file
30
server/routers/generatedLicense/types.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export type GeneratedLicenseKey = {
|
||||
instanceName: string | null;
|
||||
licenseKey: string;
|
||||
expiresAt: string;
|
||||
isValid: boolean;
|
||||
createdAt: string;
|
||||
tier: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type ListGeneratedLicenseKeysResponse = GeneratedLicenseKey[];
|
||||
|
||||
export type NewLicenseKey = {
|
||||
licenseKey: {
|
||||
id: number;
|
||||
instanceName: string | null;
|
||||
instanceId: string;
|
||||
licenseKey: string;
|
||||
tier: string;
|
||||
type: string;
|
||||
quantity: number;
|
||||
isValid: boolean;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
expiresAt: string;
|
||||
orgId: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type GenerateNewLicenseResponse = NewLicenseKey;
|
||||
11
server/routers/license/types.ts
Normal file
11
server/routers/license/types.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { LicenseStatus, LicenseKeyCache } from "@server/license/license";
|
||||
|
||||
export type ActivateLicenseStatus = LicenseStatus;
|
||||
|
||||
export type DeleteLicenseKeyResponse = LicenseStatus;
|
||||
|
||||
export type GetLicenseStatusResponse = LicenseStatus;
|
||||
|
||||
export type ListLicenseKeysResponse = LicenseKeyCache[];
|
||||
|
||||
export type RecheckStatusResponse = LicenseStatus;
|
||||
Reference in New Issue
Block a user