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 6ed8bb6
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 55 deletions.
File renamed without changes.
4 changes: 1 addition & 3 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
- name: Use Node.js 20.10
uses: actions/setup-node@v4
with:
node-version-file: 'api/.nvmrc'
node-version-file: '.nvmrc'

- uses: pnpm/action-setup@v4
with:
version: 9

- name: Install API dependencies
working-directory: api
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/client-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
- name: Use Node.js 20.10
uses: actions/setup-node@v4
with:
node-version-file: 'client/.nvmrc'
node-version-file: '.nvmrc'

- uses: pnpm/action-setup@v4
with:
version: 9

- name: Install Client dependencies
working-directory: client
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.2.0
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ We use `pnpm` for managing packages in this project. This allows us to efficient

Here are the npm scripts that you can run:

- `pnpm start:api:dev`: Starts the backend application in development mode.
- `pnpm start:client:dev`: Starts the frontend application in development mode.
- `pnpm install:client`: Installs the client application dependencies.
- `pnpm install:api`: Installs the API application dependencies.
- `pnpm build:client`: Builds the client application for production.
- `pnpm build:api`: Builds the API application for production.
- `pnpm start:client:prod`: Starts the client application in production mode.
- `pnpm start:api:prod`: Starts the API application in production mode.
- `pnpm start:prod`: Builds and starts both applications in production mode.
- `pnpm api:dev`: Starts the backend application in development mode.
- `pnpm client:dev`: Starts the frontend application in development mode.
- `pnpm client:deps`: Installs the client application dependencies.
- `pnpm api:deps`: Installs the API application dependencies.
- `pnpm client:build`: Builds the client application for production.
- `pnpm api:build`: Builds the API application for production.
- `pnpm client:prod`: Starts the client application in production mode.
- `pnpm api:prod`: Starts the API application in production mode.
- `pnpm all:prod`: Builds and starts both applications in production mode.

## TypeScript Configuration

Expand Down
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
10 changes: 8 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"strictPropertyInitialization": false,
"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:deps": "pnpm --filter api install",
"api:dev": "pnpm --filter api run start:dev",
"api:build": "pnpm --filter api run build",
"api:prod": "pnpm --filter api run start:prod",
"client:deps": "pnpm --filter client install",
"client:dev": "pnpm --filter client run dev",
"client:build": "pnpm --filter client run build",
"client:prod": "pnpm --filter client run start",
"all: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
Loading

0 comments on commit 6ed8bb6

Please sign in to comment.