Skip to content

Commit

Permalink
chore: configure nitro alias (#175)
Browse files Browse the repository at this point in the history
Co-authored-by: McPizza <gh@l1.io>
Co-authored-by: BlankParticle <blankparticle@gmail.com>
  • Loading branch information
3 people committed Mar 27, 2024
1 parent a34893d commit 7d50fe4
Show file tree
Hide file tree
Showing 43 changed files with 107 additions and 81 deletions.
4 changes: 2 additions & 2 deletions apps/mail-bridge/middleware/verifyPostalSig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validatePostalWebhookSignature } from '../utils/validatePostalWebhookSignature';
import type { PostalConfig } from '../types';
import { validatePostalWebhookSignature } from '~/utils/validatePostalWebhookSignature';
import type { PostalConfig } from '~/types';
import {
defineEventHandler,
getRequestURL,
Expand Down
10 changes: 8 additions & 2 deletions apps/mail-bridge/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ const mailDomains: MailDomains = JSON.parse(process.env.MAIL_DOMAINS);

// TODO: ensure limits are pulled from the billing module
export default defineNitroConfig({
alias: {
'~': './src'
typescript: {
tsConfig: {
compilerOptions: {
paths: {
'~/*': ['../../*']
}
}
}
},
esbuild: {
options: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mail-bridge/postal-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
import * as schema from './schema';
import { useRuntimeConfig } from '#imports';
import type { PostalConfig } from '../types';
import type { PostalConfig } from '~/types';

const postalConfig = useRuntimeConfig().postal as PostalConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { parseMessage } from '@u22n/mailtools';
import type {
MessageParseAddressPlatformObject,
postalEmailPayload
} from '../../../../types';
} from '~/types';
import { typeIdGenerator, validateTypeId } from '@u22n/utils';
import { tiptapCore, tiptapHtml } from '@u22n/tiptap';
import { tipTapExtensions } from '@u22n/tiptap/extensions';
Expand Down
4 changes: 2 additions & 2 deletions apps/mail-bridge/routes/trpc/[trpc].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createH3ApiHandler } from 'trpc-nuxt';
import { trpcMailBridgeRouter } from '../../trpc';
import { createContext } from '../../trpc/createContext';
import { trpcMailBridgeRouter } from '~/trpc';
import { createContext } from '~/trpc/createContext';

// export API handler
export default createH3ApiHandler({
Expand Down
10 changes: 5 additions & 5 deletions apps/mail-bridge/trpc/routers/domainRouter.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { z } from 'zod';
import { router, protectedProcedure } from '../trpc';
import { router, protectedProcedure } from '~/trpc/trpc';
import { and, eq } from '@u22n/database/orm';
import { postalServers } from '@u22n/database/schema';
import { typeIdValidator } from '@u22n/utils';
import type { PostalConfig } from '../../types';
import { postalDB } from '../../postal-db';
import { httpEndpoints, organizations, servers } from '../../postal-db/schema';
import type { PostalConfig } from '~/types';
import { postalDB } from '~/postal-db';
import { httpEndpoints, organizations, servers } from '~/postal-db/schema';
import {
createDomain,
setMailServerRouteForDomain,
getDomainDNSRecords,
type GetDomainDNSRecordsOutput
} from '../../postal-db/functions';
} from '~/postal-db/functions';

export const domainRouter = router({
createDomain: protectedProcedure
Expand Down
10 changes: 5 additions & 5 deletions apps/mail-bridge/trpc/routers/orgRouter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { z } from 'zod';
import { router, protectedProcedure } from '../trpc';
import { router, protectedProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { typeIdGenerator, typeIdValidator } from '@u22n/utils';
import type { PostalConfig } from '../../types';
import type { PostalConfig } from '~/types';
import {
addMailServer,
createOrg,
Expand All @@ -11,9 +11,9 @@ import {
setMailServerKey,
setMailServerRoutingHttpEndpoint,
setOrgIpPools
} from '../../postal-db/functions';
import { postalDB } from '../../postal-db';
import { ipPools } from '../../postal-db/schema';
} from '~/postal-db/functions';
import { postalDB } from '~/postal-db';
import { ipPools } from '~/postal-db/schema';

export const orgRouter = router({
createPostalOrg: protectedProcedure
Expand Down
4 changes: 2 additions & 2 deletions apps/mail-bridge/trpc/routers/sendMailRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, protectedProcedure } from '../trpc';
import { router, protectedProcedure } from '~/trpc/trpc';
import {
emailIdentities,
postalServers,
Expand All @@ -16,7 +16,7 @@ import {
} from '@u22n/database/schema';
import { typeIdValidator } from '@u22n/utils';
import { and, eq } from '@u22n/database/orm';
import type { PostalConfig } from '../../types';
import type { PostalConfig } from '~/types';
import { useRuntimeConfig } from '#imports';
import { tiptapHtml, tiptapVue3 } from '@u22n/tiptap';
import { tipTapExtensions } from '@u22n/tiptap/extensions';
Expand Down
3 changes: 2 additions & 1 deletion apps/platform/middleware/02.orgSlug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { validateOrgSlug } from '../utils/orgSlug';
import { validateOrgSlug } from '~/utils/orgSlug';
//import { validateOrgSlug } from '~/utils/orgSlug';
import { defineEventHandler } from 'h3';

export default defineEventHandler(async (event) => {
Expand Down
9 changes: 9 additions & 0 deletions apps/platform/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ if (eeLicenseKey && billingUrl && billingKey) {
}

export default defineNitroConfig({
typescript: {
tsConfig: {
compilerOptions: {
paths: {
'~/*': ['../../*']
}
}
}
},
imports: {
autoImport: false
},
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/routes/realtime/auth.post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { eventHandler, createError, readBody } from 'h3';
import { z } from 'zod';
import { realtime } from '../../realtime';
import { realtime } from '~/realtime';
import { validateTypeId } from '@u22n/utils';

const bodySchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/routes/trpc/[trpc].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createNuxtApiHandler } from 'trpc-nuxt';
import {
trpcPlatformRouter,
trpcPlatformContext as createContext
} from '../../trpc';
} from '~/trpc';

// export API handler
export default createNuxtApiHandler({
Expand Down
10 changes: 5 additions & 5 deletions apps/platform/trpc/routers/authRouter/passkeyRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { limitedProcedure, router, accountProcedure } from '../../trpc';
import { limitedProcedure, router, accountProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { accountCredentials, accounts } from '@u22n/database/schema';
import { TRPCError } from '@trpc/server';
Expand All @@ -14,12 +14,12 @@ import {
zodSchemas
} from '@u22n/utils';
import { UAParser } from 'ua-parser-js';
import { usePasskeys } from '../../../utils/auth/passkeys';
import { usePasskeysDb } from '../../../utils/auth/passkeyDbAdaptor';
import { usePasskeys } from '~/utils/auth/passkeys';
import { usePasskeysDb } from '~/utils/auth/passkeyDbAdaptor';
import { setCookie, getCookie, getHeader } from 'h3';
import { lucia } from '../../../utils/auth';
import { lucia } from '~/utils/auth';
import { validateUsername } from './signupRouter';
import { createLuciaSessionCookie } from '../../../utils/session';
import { createLuciaSessionCookie } from '~/utils/session';

export const passkeyRouter = router({
// generateNewPasskeyChallenge: accountProcedure
Expand Down
6 changes: 3 additions & 3 deletions apps/platform/trpc/routers/authRouter/passwordRouter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { z } from 'zod';
import { Argon2id } from 'oslo/password';
import { limitedProcedure, router, accountProcedure } from '../../trpc';
import { limitedProcedure, router, accountProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { accountCredentials, accounts } from '@u22n/database/schema';
import { strongPasswordSchema, typeIdGenerator, zodSchemas } from '@u22n/utils';
import { TRPCError } from '@trpc/server';
import { createError, setCookie } from 'h3';
import { lucia } from '../../../utils/auth';
import { lucia } from '~/utils/auth';
import { validateUsername } from './signupRouter';
import { createLuciaSessionCookie } from '../../../utils/session';
import { createLuciaSessionCookie } from '~/utils/session';
import { decodeHex } from 'oslo/encoding';
import { TOTPController } from 'oslo/otp';

Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/authRouter/signupRouter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { router, limitedProcedure } from '../../trpc';
import { router, limitedProcedure } from '~/trpc/trpc';
import type { DBType } from '@u22n/database';
import { eq } from '@u22n/database/orm';
import { accounts } from '@u22n/database/schema';
import { blockedUsernames, reservedUsernames } from '../../../utils/signup';
import { blockedUsernames, reservedUsernames } from '~/utils/signup';
import { calculatePasswordStrength, zodSchemas } from '@u22n/utils';

export async function validateUsername(
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/authRouter/twoFactorRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, accountProcedure } from '../../trpc';
import { router, accountProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { accountCredentials, accounts } from '@u22n/database/schema';
import { decodeHex, encodeHex } from 'oslo/encoding';
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/contactRouter/contactRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { and, eq } from '@u22n/database/orm';
import { contacts } from '@u22n/database/schema';
import { TRPCError } from '@trpc/server';
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/convoRouter/convoRouter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mailBridgeTrpcClient } from './../../../utils/tRPCServerClients';
import { mailBridgeTrpcClient } from '~/utils/tRPCServerClients';
import { z } from 'zod';
import { parse } from 'superjson';
import { router, orgProcedure } from '../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import {
type InferInsertModel,
and,
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/convoRouter/entryRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { and, desc, eq, lt, or } from '@u22n/database/orm';
import { convos, convoEntries } from '@u22n/database/schema';
import { typeIdValidator } from '@u22n/utils';
Expand Down
6 changes: 3 additions & 3 deletions apps/platform/trpc/routers/orgRouter/mail/domainsRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { and, eq } from '@u22n/database/orm';
import {
domains,
Expand All @@ -8,8 +8,8 @@ import {
} from '@u22n/database/schema';
import { typeIdGenerator, typeIdValidator } from '@u22n/utils';
import { TRPCError } from '@trpc/server';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { mailBridgeTrpcClient } from '../../../../utils/tRPCServerClients';
import { isAccountAdminOfOrg } from '~/utils/account';
import { mailBridgeTrpcClient } from '~/utils/tRPCServerClients';
import { lookupNS } from '@u22n/utils/dns';

export const domainsRouter = router({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import {
and,
eq,
Expand All @@ -17,7 +17,7 @@ import {
groupMembers
} from '@u22n/database/schema';
import { typeIdGenerator, typeIdValidator } from '@u22n/utils';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { isAccountAdminOfOrg } from '~/utils/account';
import { TRPCError } from '@trpc/server';

export const emailIdentityRouter = router({
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/orgRouter/orgCrudRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, accountProcedure } from '../../trpc';
import { router, accountProcedure } from '~/trpc/trpc';
import type { DBType } from '@u22n/database';
import { eq, and } from '@u22n/database/orm';
import {
Expand All @@ -10,7 +10,7 @@ import {
} from '@u22n/database/schema';
import { typeIdGenerator } from '@u22n/utils';
import { TRPCError } from '@trpc/server';
import { blockedUsernames, reservedUsernames } from '../../../utils/signup';
import { blockedUsernames, reservedUsernames } from '~/utils/signup';

async function validateOrgSlug(
db: DBType,
Expand Down
6 changes: 3 additions & 3 deletions apps/platform/trpc/routers/orgRouter/setup/billingRouter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { z } from 'zod';
import { router, eeProcedure } from '../../../trpc';
import { router, eeProcedure } from '~/trpc/trpc';
import { eq, and, sql } from '@u22n/database/orm';
import { orgBilling, orgMembers } from '@u22n/database/schema';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { isAccountAdminOfOrg } from '~/utils/account';
import { TRPCError } from '@trpc/server';
import { billingTrpcClient } from '../../../../utils/tRPCServerClients';
import { billingTrpcClient } from '~/utils/tRPCServerClients';

export const billingRouter = router({
getOrgBillingOverview: eeProcedure
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/orgRouter/setup/profileRouter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { orgs } from '@u22n/database/schema';
import { typeIdValidator } from '@u22n/utils';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { isAccountAdminOfOrg } from '~/utils/account';
import { TRPCError } from '@trpc/server';

export const orgProfileRouter = router({
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/orgRouter/users/groupsRouter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { eq, and } from '@u22n/database/orm';
import { orgMembers, groupMembers, groups } from '@u22n/database/schema';
import { typeIdGenerator, typeIdValidator } from '@u22n/utils';
import { uiColors } from '@u22n/types/ui';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { isAccountAdminOfOrg } from '~/utils/account';
import { TRPCError } from '@trpc/server';

export const groupsRouter = router({
Expand Down
8 changes: 4 additions & 4 deletions apps/platform/trpc/routers/orgRouter/users/invitesRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
orgProcedure,
limitedProcedure,
accountProcedure
} from '../../../trpc';
} from '~/trpc/trpc';
import { eq, inArray } from '@u22n/database/orm';
import {
domains,
Expand All @@ -25,11 +25,11 @@ import {
typeIdValidator,
zodSchemas
} from '@u22n/utils';
import { refreshOrgSlugCache } from '../../../../utils/orgSlug';
import { isAccountAdminOfOrg } from '../../../../utils/account';
import { refreshOrgSlugCache } from '~/utils/orgSlug';
import { isAccountAdminOfOrg } from '~/utils/account';
import { TRPCError } from '@trpc/server';
import { useRuntimeConfig } from '#imports';
import { billingTrpcClient } from '../../../../utils/tRPCServerClients';
import { billingTrpcClient } from '~/utils/tRPCServerClients';

export const invitesRouter = router({
createNewInvite: orgProcedure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, orgProcedure } from '../../../trpc';
import { router, orgProcedure } from '~/trpc/trpc';
import { eq, and, or } from '@u22n/database/orm';
import { orgs, orgMembers } from '@u22n/database/schema';
import { TRPCError } from '@trpc/server';
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/testRouter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { router, publicProcedure } from '../trpc';
import { router, publicProcedure } from '~/trpc/trpc';
import { TRPCError } from '@trpc/server';

// TODO: Figure out what to do with this route
Expand Down
4 changes: 2 additions & 2 deletions apps/platform/trpc/routers/userRouter/addressRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TRPCError } from '@trpc/server';
import { z } from 'zod';
import { orgProcedure, router, accountProcedure } from '../../trpc';
import { orgProcedure, router, accountProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import {
emailIdentities,
Expand All @@ -13,7 +13,7 @@ import {

import { orgMembers } from '@u22n/database/schema';
import { useRuntimeConfig } from '#imports';
import type { MailDomains } from '../../../types';
import type { MailDomains } from '~/types';
import { typeIdGenerator, typeIdValidator } from '@u22n/utils';

export const addressRouter = router({
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/userRouter/defaultsRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, accountProcedure } from '../../trpc';
import { router, accountProcedure } from '~/trpc/trpc';
import { eq } from '@u22n/database/orm';
import { accounts } from '@u22n/database/schema';

Expand Down
2 changes: 1 addition & 1 deletion apps/platform/trpc/routers/userRouter/profileRouter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { router, accountProcedure } from '../../trpc';
import { router, accountProcedure } from '~/trpc/trpc';
import { and, eq } from '@u22n/database/orm';
import { orgMemberProfiles, orgs, orgMembers } from '@u22n/database/schema';
import { typeIdValidator } from '@u22n/utils';
Expand Down

0 comments on commit 7d50fe4

Please sign in to comment.