tsconfig, multiple package paths

This commit is contained in:
Max Peintner
2023-04-20 12:55:39 +02:00
parent caf5f1d512
commit 26cf9132a0
14 changed files with 46 additions and 26 deletions

View File

@@ -1,4 +1,7 @@
import { ZitadelOptions, getApps, initializeApp } from "@zitadel/server";
import { ZitadelOptions } from "@zitadel/server";
import { getAuth } from "@zitadel/server/auth";
import { getApp, getApps, initializeApp } from "@zitadel/server/app";
export const zitadelConfig: ZitadelOptions = {
apiUrl: process.env.ZITADEL_API_URL ?? "",
@@ -11,5 +14,10 @@ if (!getApps().length) {
initializeApp(zitadelConfig);
}
// const app = getApp();
// const auth = getAuth();
const app = getApp();
export async function getMyUser(): Promise<GetMyUserResponse> {
const auth = await getAuth();
const response = await auth.getMyUser({});
return response;
}

View File

@@ -10,8 +10,8 @@
"dist/**"
],
"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"build": "tsup src/index.ts src/auth/index.ts src/app/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts src/auth/index.ts src/app/index.ts --format esm,cjs --watch --dts",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"prebuild": "pnpm run generate",

View File

@@ -1,15 +1,11 @@
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
import { createChannel, createClientFactory } from "nice-grpc";
import {
AuthServiceClient,
AuthServiceDefinition,
} from "./proto/server/zitadel/auth";
import {
AdminServiceClient,
AdminServiceDefinition,
} from "./proto/server/zitadel/admin";
import { authMiddleware } from "./middleware";
} from "../proto/server/zitadel/admin";
import { authMiddleware } from "../middleware";
const createClient = <Client>(
definition: CompatServiceDefinition,

View File

@@ -0,0 +1 @@
export * from "./admin";

View File

@@ -0,0 +1 @@
export * from "./app";

View File

@@ -3,9 +3,10 @@ import { createChannel, createClientFactory } from "nice-grpc";
import {
AuthServiceClient,
AuthServiceDefinition,
} from "./proto/server/zitadel/auth";
import { ZitadelApp } from "./app";
import { authMiddleware } from "./middleware";
GetMyUserResponse,
} from "../proto/server/zitadel/auth";
import { ZitadelApp } from "../app/app";
import { authMiddleware } from "../middleware";
const createClient = <Client>(
definition: CompatServiceDefinition,
@@ -23,3 +24,9 @@ export async function getAuth(app?: ZitadelApp): Promise<AuthServiceClient> {
""
);
}
export async function getMyUser(): Promise<GetMyUserResponse> {
const auth = await getAuth();
const response = await auth.getMyUser({});
return response;
}

View File

@@ -0,0 +1,2 @@
export * from "../proto/server/zitadel/auth";
export { getAuth } from "./auth";

View File

@@ -1,8 +1,11 @@
export { initializeApp, getApps } from "./app";
export * from "./app/app";
export { getAuth } from "./auth";
export { getManagement } from "./management";
export { getAdmin } from "./admin";
export { getSystem } from "./system";
export * as auth from "./auth";
export * as management from "./management";
export * as admin from "./admin";
export * as system from "./system";
export type { ZitadelOptions } from "./app";
// export * as proto from "./proto/server/zitadel/*";
// export * from "./proto/server/zitadel/management";
// export * from "./proto/server/zitadel/system";
// export * from "./proto/server/zitadel/admin";

View File

@@ -0,0 +1 @@
export * from "./management";

View File

@@ -4,10 +4,10 @@ import { createChannel, createClientFactory } from "nice-grpc";
import {
ManagementServiceClient,
ManagementServiceDefinition,
} from "./proto/server/zitadel/management";
} from "../proto/server/zitadel/management";
import { authMiddleware } from "./middleware";
import { ZitadelApp, getApps } from "./app";
import { authMiddleware } from "../middleware";
import { ZitadelApp, getApps } from "../app/app";
const createClient = <Client>(
definition: CompatServiceDefinition,

View File

@@ -0,0 +1 @@
export * from "./system";

View File

@@ -5,8 +5,8 @@ import { createChannel, createClientFactory } from "nice-grpc";
import {
SystemServiceClient,
SystemServiceDefinition,
} from "./proto/server/zitadel/system";
import { authMiddleware } from "./middleware";
} from "../proto/server/zitadel/system";
import { authMiddleware } from "../middleware";
const createSystemClient = <Client>(
definition: CompatServiceDefinition,

View File

@@ -1,6 +1,6 @@
{
"extends": "@zitadel/tsconfig/node14.json",
"include": ["."],
"include": ["src/**/*"],
"compilerOptions": {
"baseUrl": "."
},