Skip to content

Commit

Permalink
fix wront import path and add special tsinfo for eslint on core to in…
Browse files Browse the repository at this point in the history
…clude tests
  • Loading branch information
Thiago Felix authored and Thiago Felix committed Sep 24, 2024
1 parent 3eaf771 commit 9948a63
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 19 deletions.
3 changes: 1 addition & 2 deletions apps/nextjs/src/app/(auth)/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
captureException,
withServerActionInstrumentation,
} from "@sentry/nextjs";
import { env } from "#env";

import type { Cookie } from "@acme/core/entities/models/cookie";
import { signInController } from "@acme/core/controllers/auth/sign-in.controller";
Expand All @@ -17,8 +18,6 @@ import {
} from "@acme/core/entities/errors/auth";
import { InputParseError } from "@acme/core/entities/errors/common";

import { env } from "../../../../../packages/core/dist/src/env";

export async function signUp(formData: FormData) {
return await withServerActionInstrumentation(
"signUp",
Expand Down
3 changes: 1 addition & 2 deletions apps/nextjs/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
captureException,
withServerActionInstrumentation,
} from "@sentry/nextjs";
import { env } from "#env";

import { createTodoController } from "@acme/core/controllers/todos/create-todo.controller";
import { toggleTodoController } from "@acme/core/controllers/todos/toggle-todo.controller";
Expand All @@ -15,8 +16,6 @@ import {
NotFoundError,
} from "@acme/core/entities/errors/common";

import { env } from "../../../../packages/core/dist/src/env";

export async function createTodo(formData: FormData) {
return await withServerActionInstrumentation(
"createTodo",
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { captureException, startSpan } from "@sentry/nextjs";
import { env } from "#env";

import { getTodosForUserController } from "@acme/core/controllers/todos/get-todos-for-user.controller";
import {
Expand All @@ -10,7 +11,6 @@ import {
import { Card, CardContent, CardHeader, CardTitle } from "@acme/ui/card";
import { Separator } from "@acme/ui/separator";

import { env } from "../../../../packages/core/dist/src/env";
import { UserMenu } from "./_components/user-menu";
import { CreateTodo } from "./add-todo";
import { Todos } from "./todos";
Expand Down
5 changes: 2 additions & 3 deletions apps/nextjs/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

import { env as coreEnv } from "../../../packages/core/dist/src/env";
import { env as coreEnv } from "@acme/core/env";

export const env = createEnv({
extends: [coreEnv],
Expand All @@ -15,8 +15,7 @@ export const env = createEnv({
* This way you can ensure the app isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z.string().url(),
NEXT_RUNTIME: z.string().optional(),
NEXT_RUNTIME: z.enum(["nodejs", "edge"]).optional(),
},

/**
Expand Down
8 changes: 8 additions & 0 deletions packages/core/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ export default [
"@typescript-eslint/no-floating-promises": "off",
},
},
{
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
projectService: false,
},
},
},
];
5 changes: 4 additions & 1 deletion packages/core/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export const env = createEnv({
.enum(["development", "production", "test"])
.default("development"),
},
runtimeEnv: process.env,
runtimeEnvStrict: {
SESSION_COOKIE: process.env.SESSION_COOKIE,
NODE_ENV: process.env.NODE_ENV,
},
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import "reflect-metadata";

import { env } from "#config";
import { signInController } from "#controllers/auth/sign-in.controller";
import { destroyContainer, initializeContainer } from "#di/container";
import { AuthenticationError } from "#entities/errors/auth";
import { InputParseError } from "#entities/errors/common";
import { env } from "#env";
import { afterEach, beforeEach, expect, it } from "vitest";

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "reflect-metadata";

import { env } from "#config";
import { env } from "#env";
import { signOutController } from "#controllers/auth/sign-out.controller";
import { destroyContainer, initializeContainer } from "#di/container";
import { InputParseError } from "#entities/errors/common";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "reflect-metadata";

import { env } from "#config";
import { env } from "#env";
import { signUpController } from "#controllers/auth/sign-up.controller";
import { destroyContainer, initializeContainer } from "#di/container";
import { AuthenticationError } from "#entities/errors/auth";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "reflect-metadata";

import { env } from "#config";
import { env } from "#env";
import { destroyContainer, initializeContainer } from "#di/container";
import { signInUseCase } from "#use-cases/auth/sign-in.use-case";
import { signOutUseCase } from "#use-cases/auth/sign-out.use-case";
Expand Down
9 changes: 9 additions & 0 deletions packages/core/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@acme/tsconfig/internal-package.json",
"compilerOptions": {
"rootDir": ".",
"types": ["reflect-metadata"]
},
"include": ["src", "tests"],
"exclude": ["node_modules"]
}
13 changes: 7 additions & 6 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
"cache": false
}
},
"globalEnv": ["PORT", "DATABASE_URL", "DATABASE_AUTH_TOKEN"],
"globalPassThroughEnv": [
"globalEnv": [
"NODE_ENV",
"NEXT_RUNTIME",
"CI",
"npm_lifecycle_event"
]
"SESSION_COOKIE",
"PORT",
"DATABASE_URL",
"DATABASE_AUTH_TOKEN"
],
"globalPassThroughEnv": []
}

0 comments on commit 9948a63

Please sign in to comment.