Skip to content

Commit

Permalink
Update backend configuration and improve ESLint setup; add .js extens…
Browse files Browse the repository at this point in the history
…ions, refine tsconfig, and enhance tsup settings
  • Loading branch information
valon-loshaj committed Nov 12, 2024
1 parent 420bcbc commit 065f83e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 47 deletions.
13 changes: 3 additions & 10 deletions apps/backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { fileURLToPath } from "url";
import { dirname } from "path";
import app from "./app";
import { createServer } from "./server";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// apps/backend/src/index.ts
import { createServer } from "./server.js"; // Add .js extension
import app from "./app.js"; // Add .js extension

const server = createServer(app);
server.listen(process.env.PORT || 3000, () => {
console.log(`Server running on port ${process.env.PORT || 3000}`);
});

export { server };
2 changes: 0 additions & 2 deletions apps/backend/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// apps/backend/src/server.ts
import { Server } from "http";
import express from "express";
import type { Express } from "express";

export function createServer(app: Express): Server {
Expand Down
90 changes: 59 additions & 31 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,66 @@ const compat = new FlatCompat({
baseDirectory: __dirname,
});

export default tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
export default [
{
plugins: {
n: eslintPluginN,
import: eslintPluginImport,
},
rules: {
"n/no-missing-import": "error",
"import/no-unresolved": "error",
},
},
prettier,
...compat.config({
extends: ["plugin:import/typescript"],
settings: {
"import/resolver": {
typescript: {
project: ["./apps/*/tsconfig.json"],
// Config files
files: ["*.config.{js,ts}", ".eslintrc.{js,cjs,mjs}"],
...tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
parserOptions: {
project: null, // Disable project for config files
},
},
node: true,
},
},
}),
}
),
},
{
ignores: ["**/dist/**", "**/node_modules/**", "**/.next/**"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.json", "./apps/*/tsconfig.json"],
tsconfigRootDir: __dirname,
// Source files
files: ["apps/**/*.{ts,tsx}"],
...tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
{
plugins: {
n: eslintPluginN,
import: eslintPluginImport,
},
rules: {
"n/no-missing-import": "error",
"import/no-unresolved": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
},
},
},
}
);
prettier,
...compat.config({
extends: ["plugin:import/typescript"],
settings: {
"import/resolver": {
typescript: {
project: ["./apps/*/tsconfig.json"],
},
node: true,
},
},
}),
{
ignores: ["**/dist/**", "**/node_modules/**", "**/.next/**"],
languageOptions: {
parserOptions: {
project: ["./apps/*/tsconfig.json"],
tsconfigRootDir: __dirname,
},
},
}
),
},
];
11 changes: 7 additions & 4 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ export default defineConfig([
{
entry: ["apps/backend/src/index.ts"],
outDir: "apps/backend/dist",
format: ["esm"], // Ensure this is set to "esm"
dts: true,
clean: true,
tsconfig: "./apps/backend/tsconfig.json",
format: ["esm"],
target: "node20",
platform: "node",
sourcemap: true,
bundle: true,
splitting: false,
noExternal: ["express"],
},
// Frontend config
{
Expand Down

0 comments on commit 065f83e

Please sign in to comment.