Skip to content

Commit

Permalink
Next and Nestjs apps, upgrade libs (#6)
Browse files Browse the repository at this point in the history
* apps folder

* turborepo initial setup

* fix missing turbo scripts

* fix fastify server build

* minor fix

* github actions changes

* add Dockerfiles

* minor changes

* updated packages

* build frontend success

* build images success

* wip

* wip

* prod grade dockerfiles

* upgrade root pkgs

* upgrade frontend packages wip

ts-eslint in nest pkg.json issue

fix frontend build issue

add nextjs app

* update corelib pkgs

* react pkg setup done

* upgrade next-client pkgs

* next-client config wip

* add latest nestjs

* eslint wip

* eslint and prettier setup

* config lint-staged

* add nestjs and express server

* next-client runs sorta

* upgrade root pkgs

* express-server pkg update npm pkgs to latest

* update frontend pkg npm modules

* update nestjs-server pkg npm modules

* next-client done
  • Loading branch information
nishkohli96 authored Feb 11, 2024
1 parent 79074d0 commit 825eb90
Show file tree
Hide file tree
Showing 122 changed files with 7,308 additions and 4,651 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist
build
coverage
.next
.turbo
.eslintrc.js
*.d.ts
62 changes: 31 additions & 31 deletions .github/workflows/docker-img.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
name: ci
# name: ci

on:
push:
branches:
- 'main'
# on:
# push:
# branches:
# - 'main'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
# jobs:
# docker:
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y_%m_%d_%H_%m')"
# - name: Get current date
# id: date
# run: echo "::set-output name=date::$(date +'%Y_%m_%d_%H_%m')"

- name: Build Server Image
run: docker build -f ./apps/fastify-server/Dockerfile -t ${{secrets.DOCKER_HUB_USERNAME}}/rnm-server:${{ steps.date.outputs.date }} .
# - name: Build Server Image
# run: docker build -f ./apps/fastify-server/Dockerfile -t ${{secrets.DOCKER_HUB_USERNAME}}/rnm-server:${{ steps.date.outputs.date }} .

- name: Build Frontend Image
run: docker build -f ./apps/frontend/Dockerfile -t ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-frontend:${{ steps.date.outputs.date }} .
# - name: Build Frontend Image
# run: docker build -f ./apps/frontend/Dockerfile -t ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-frontend:${{ steps.date.outputs.date }} .

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
# - name: Login to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Push Backend Image to Docker Hub
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-server:${{ steps.date.outputs.date }}
# - name: Push Backend Image to Docker Hub
# run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-server:${{ steps.date.outputs.date }}

- name: Push Frontend Image to Docker Hub
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-frontend:${{ steps.date.outputs.date }}
# - name: Push Frontend Image to Docker Hub
# run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/rnm-frontend:${{ steps.date.outputs.date }}
50 changes: 25 additions & 25 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: github-actions
# name: github-actions

on: [push]
# on: [push]

jobs:
build:
runs-on: ubuntu-latest
# jobs:
# build:
# runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.15.0]
os: [ubuntu-latest, macos-latest]
# strategy:
# matrix:
# node-version: [20.10.0]
# os: [ubuntu-latest]

steps:
- name: Git Checkout
uses: actions/checkout@v2
# steps:
# - name: Git Checkout
# uses: actions/checkout@v4

- name: Setup Node env
uses: actions/setup-node@v2.1.4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
# - name: Setup Node env
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'yarn'

- name: Install dependencies
run: yarn
# - name: Install dependencies
# run: yarn

- name: Build @core/lib
run: yarn build:lib
# - name: Build @core/lib
# run: yarn lib:build

- name: Build frontend
run: yarn frontend:build
# - name: Build frontend
# run: yarn frontend:build

- name: Build fastify-server
run: yarn fastify-server:build
# - name: Build fastify-server
# run: yarn fastify-server:build
43 changes: 30 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
# folders
node_modules
.pnp
.pnp.js
.turbo
.next
.vercel
logs

# production
build
dist
*.tsbuildinfo

# testing
/coverage

# production
apps/**/build
apps/**/dist
**.tsbuildinfo
/.nyc_output

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.*
*.log
.pnp.js
*.pem
next-env.d.ts

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

npm-debug.log*
yarn-debug.log*
yarn-error.log*
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
6 changes: 1 addition & 5 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npx lint-staged
npx lint-staged
46 changes: 35 additions & 11 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
# folders
node_modules
public
build
dist
.next
.vercel

src/assets/images
src/assets/icons

.env
.env.prod
.env.testing
# config-files
nest-cli.json
package.json
package-lock.json
test/jest-e2e.json
tsconfig.json
tsconfig.build.json
turbo.json
yarn.lock

.eslintrc.json
.eslintrc
.eslintrc.*
.eslintcache

.gitignore
.prettierignore
.prettierrc
.prettierrc.*
.tsbuildinfo

yarn.lock
yarn-error.log
# static asset files
*.jpg
*.jpeg
*.png
*.svg
*.otf
*.ttf
*.woff

README.md
# custom files
*.js
*.jsx
*.ts
*.tsx
*.md
*.log
*.d.ts
*.yml
*.yaml
20 changes: 13 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"printWidth": 80,
"singleQuote": true,
"useTabs": true,
"tabWidth": 4,
"semi": true,
"bracketSpacing": true
}
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"printWidth": 80,
"semi": true,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ yarn
Build the `@core/lib` first.

```
yarn build:lib
yarn lib:build
```

Run the `frontend` and `fastify-server` in one command thanks to [Turborepo's Pipelines](https://turborepo.org/docs/core-concepts/pipelines)

```
yarn dev
```
Build, run, lint or test all your apps in one command thanks to [Turborepo's Pipelines](https://turborepo.org/docs/core-concepts/pipelines)

## Support Me

Expand Down
3 changes: 3 additions & 0 deletions apps/express-server/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@nish1896']
}
31 changes: 31 additions & 0 deletions apps/express-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Base Image
FROM node:20-alpine3.18 as phase1

WORKDIR /app

# Run yarn only if package.json changes
# copied tsconfig as shared-ui's tsconfig extends rootDir's tsconfig
COPY turbo.json .
COPY tsconfig.json .
COPY package.json .

# first create these directories, else the copying won't work.
RUN mkdir -p packages/shared
RUN mkdir -p apps/server

# copying only the required packages
COPY ./packages/shared/package.json packages/shared
COPY ./packages/shared packages/shared

COPY ./apps/server/package.json apps/server
COPY ./apps/server apps/server

# install node_modules
RUN yarn
RUN yarn build:lib

# build server
RUN yarn build-apps

# run server in dev env
CMD ["yarn", "workspace ecom-mern-server", "build:run"]
3 changes: 3 additions & 0 deletions apps/express-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# express-server

Express JS Application with Typescript
28 changes: 28 additions & 0 deletions apps/express-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "express-server",
"author": "Nishant Kohli",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nodemon -r tsconfig-paths/register src/index.ts",
"build": "rimraf dist & tsc",
"build:run": "ts-node dist/index.js",
"lint": "eslint --fix ."
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.2",
"winston": "3.11.0"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.11.17",
"eslint": "^8.56.0",
"nodemon": "^3.0.3",
"rimraf": "^5.0.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.3"
}
}
10 changes: 10 additions & 0 deletions apps/express-server/src/app-constants/env_vars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Define all environment variables in this file and then
* export across other modules.
*/

const env = process.env;

export const ENV_VARS = Object.freeze({
port: env.port ?? 5000,
});
1 change: 1 addition & 0 deletions apps/express-server/src/app-constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './env_vars';
Loading

0 comments on commit 825eb90

Please sign in to comment.