mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-15 17:36:37 +00:00
♻️ make fossorial remote API only configurable on the frontend and only in DEV
This commit is contained in:
@@ -6,7 +6,6 @@ import { eq } from "drizzle-orm";
|
||||
import { configSchema, readConfigFile } from "./readConfigFile";
|
||||
import { fromError } from "zod-validation-error";
|
||||
import { build } from "@server/build";
|
||||
import { pullEnv } from "@app/lib/pullEnv";
|
||||
|
||||
export class Config {
|
||||
private rawConfig!: z.infer<typeof configSchema>;
|
||||
@@ -150,7 +149,6 @@ export class Config {
|
||||
|
||||
public async checkSupporterKey() {
|
||||
const [key] = await db.select().from(supporterKey).limit(1);
|
||||
const env = pullEnv();
|
||||
|
||||
if (!key) {
|
||||
return;
|
||||
@@ -160,7 +158,7 @@ export class Config {
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${env.app.fossorialRemoteAPIBaseUrl}/api/v1/license/validate`,
|
||||
`https://api.fossorial.io/api/v1/license/validate`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
@@ -18,13 +18,11 @@ import logger from "@server/logger";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import privateConfig from "#private/lib/config";
|
||||
import { GenerateNewLicenseResponse } from "@server/routers/generatedLicense/types";
|
||||
import { pullEnv } from "@app/lib/pullEnv";
|
||||
|
||||
async function createNewLicense(orgId: string, licenseData: any): Promise<any> {
|
||||
try {
|
||||
const env = pullEnv();
|
||||
const response = await fetch(
|
||||
`${env.app.fossorialRemoteAPIBaseUrl}/api/v1/license-internal/enterprise/${orgId}/create`,
|
||||
`https://api.fossorial.io/api/v1/license-internal/enterprise/${orgId}/create`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
|
||||
@@ -21,13 +21,11 @@ import {
|
||||
GeneratedLicenseKey,
|
||||
ListGeneratedLicenseKeysResponse
|
||||
} from "@server/routers/generatedLicense/types";
|
||||
import { pullEnv } from "@app/lib/pullEnv";
|
||||
|
||||
async function fetchLicenseKeys(orgId: string): Promise<any> {
|
||||
try {
|
||||
const env = pullEnv();
|
||||
const response = await fetch(
|
||||
`${env.app.fossorialRemoteAPIBaseUrl}/api/v1/license-internal/enterprise/${orgId}/list`,
|
||||
`https://api.fossorial.io/api/v1/license-internal/enterprise/${orgId}/list`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -5,12 +5,9 @@ import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { fromError } from "zod-validation-error";
|
||||
import { response as sendResponse } from "@server/lib/response";
|
||||
import { suppressDeprecationWarnings } from "moment";
|
||||
import { supporterKey } from "@server/db";
|
||||
import { db } from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import config from "@server/lib/config";
|
||||
import { pullEnv } from "@app/lib/pullEnv";
|
||||
|
||||
const validateSupporterKeySchema = z
|
||||
.object({
|
||||
@@ -32,7 +29,6 @@ export async function validateSupporterKey(
|
||||
next: NextFunction
|
||||
): Promise<any> {
|
||||
try {
|
||||
const env = pullEnv();
|
||||
const parsedBody = validateSupporterKeySchema.safeParse(req.body);
|
||||
if (!parsedBody.success) {
|
||||
return next(
|
||||
@@ -46,7 +42,7 @@ export async function validateSupporterKey(
|
||||
const { githubUsername, key } = parsedBody.data;
|
||||
|
||||
const response = await fetch(
|
||||
`${env.app.fossorialRemoteAPIBaseUrl}/api/v1/license/validate`,
|
||||
`https://api.fossorial.io/api/v1/license/validate`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user