Skip to content

Commit

Permalink
improvements to mono repo
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed May 16, 2024
1 parent d9fb86f commit b5ff5a9
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 40 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.2.0
1 change: 0 additions & 1 deletion api/.nvmrc

This file was deleted.

1 change: 0 additions & 1 deletion client/.nvmrc

This file was deleted.

8 changes: 5 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"test": "jest"
},
"dependencies": {
"@tanstack/react-query": "^5.36.2",
"@ts-rest/react-query": "^3.45.2",
"clsx": "2.1.1",
"lucide-react": "0.378.0",
"next": "14.2.3",
Expand All @@ -18,7 +20,6 @@
"tailwind-merge": "2.3.0"
},
"devDependencies": {
"shared": "workspace:*",
"@testing-library/jest-dom": "^5.4.5",
"@testing-library/react": "^15.0.7",
"@types/jest": "^29.5.12",
Expand All @@ -36,8 +37,9 @@
"jest-environment-jsdom": "^29.7.0",
"postcss": "^8",
"prettier": "^3.2.5",
"shared": "workspace:*",
"tailwindcss": "^3.4.1",
"typescript": "^5.1.3",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"typescript": "^5.1.3"
}
}
2 changes: 1 addition & 1 deletion client/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inter } from "next/font/google";

import type { Metadata } from "next";
import "@client/src/app/globals.css";
import "@/app/globals.css";

const inter = Inter({ subsets: ["latin"] });

Expand Down
3 changes: 2 additions & 1 deletion client/src/containers/coming-soon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Image from "next/image";

import { BarChartHorizontal, Filter } from "lucide-react";

import Wrapper from "@client/src/containers/wrapper";
import Wrapper from "@/containers/wrapper";

export default function ComingSoon() {
return (
<Wrapper className="lg:px-24 pt-0.5 lg:pt-20">
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from "react";

import { cn } from "@client/src/utils/cn";
import { cn } from "@/utils/cn";

const Wrapper = ({
children,
Expand Down
9 changes: 7 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"strictPropertyInitialization": false,
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@shared/*": ["../shared/*"],
"@/*": [
"./src/*"
]
}
},
"include": [
"src/**/*",
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "4-growth",
"version": "1.0.0",
"description": "4-growth mono-repo",
"description": "4-growth platform",
"scripts": {
"start:api:dev": "pnpm --filter api run start:dev",
"start:client:dev": "pnpm --filter client run dev",
"install:client": "pnpm --filter client install",
"install:api": "pnpm --filter api install",
"build:client": "pnpm --filter client run build",
"build:api": "pnpm --filter api run build",
"start:client:prod": "pnpm --filter client run start",
"start:api:prod": "pnpm --filter api run start:prod",
"start:prod": "pnpm run build:client && pnpm run build:api && pnpm run start:client:prod & pnpm run start:api:prod"
}
"api:install": "pnpm --filter api install",
"api:start:dev": "pnpm --filter api run start:dev",
"api:build": "pnpm --filter api run build",
"api:start:prod": "pnpm --filter api run start:prod",
"client:install": "pnpm --filter client install",
"client:start:dev": "pnpm --filter client run dev",
"client:build": "pnpm --filter client run build",
"client:start:prod": "pnpm --filter client run start",
"all:start:prod": "pnpm run build:client && pnpm run build:api && pnpm run start:client:prod & pnpm run start:api:prod"
},
"packageManager": "[email protected]"
}
59 changes: 56 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shared/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
24 changes: 24 additions & 0 deletions shared/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
4 changes: 4 additions & 0 deletions shared/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
35 changes: 25 additions & 10 deletions shared/contracts/user.contract.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
import { initContract } from "@ts-rest/core";
import { User } from "@shared/dto/users/user.entity";
import { UpdateUserDto } from "@shared/dto/users/update-user.dto";
import { CreateUserDto } from "@shared/dto/users/create-user.dto";
import { initContract } from '@ts-rest/core';
import { User } from '@shared/dto/users/user.entity';
import { UpdateUserDto } from '@shared/dto/users/update-user.dto';
import { CreateUserDto } from '@shared/dto/users/create-user.dto';

import * as z from 'zod';

const contract = initContract();
export const userContract = contract.router({
createUser: {
method: "POST",
path: "/users",
method: 'POST',
path: '/users',
responses: {
201: contract.type<CreateUserDto>(),
},
body: contract.type<User>(),
summary: "Create a new user",
summary: 'Create a new user',
},
updateUser: {
method: "PUT",
path: "/users/:id",
method: 'PUT',
path: '/users/:id',
responses: {
200: contract.type<User>(),
},
body: contract.type<UpdateUserDto>(),
summary: "Update an existing user",
summary: 'Update an existing user',
},
getUsers: {
method: 'GET',
path: '/users',
responses: {
200: contract.type<User[]>(),
},
query: z.object({
take: z.string().transform(Number).optional(),
skip: z.string().transform(Number).optional(),
search: z.string().optional(),
}),
summary: 'Get all users',
},
});
3 changes: 1 addition & 2 deletions shared/dto/users/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
BaseEntity,
Column,
CreateDateColumn,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';

export class User extends BaseEntity {
export class User {
@PrimaryGeneratedColumn()
id: number;

Expand Down
12 changes: 8 additions & 4 deletions shared/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"name": "shared",
"private": true,
"packageManager": "[email protected]",
"dependencies": {
"@ts-rest/core": "^3.45.2",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"config": "^3.3.11",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"typeorm": "^0.3.20",
"zod": "^3.23.8",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1"
"zod": "^3.23.8"
}
}

0 comments on commit b5ff5a9

Please sign in to comment.