Skip to content

Commit 0a8bbf2

Browse files
authored
Lib upgrade oct24 (#13)
* alias imports fix * fix build issues of express-server * express app upgrade pkgs * upgrade nestjs server * upgrade nextjs dependencies except MUI * update express-server readme * upgrade to mui v6 in next-client * update next-client mui * upgrade react dependencies * upgrade web-vitals, fix test cases failing to run
1 parent b3cf3be commit 0a8bbf2

File tree

34 files changed

+2283
-2152
lines changed

34 files changed

+2283
-2152
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
**The ideal repository for full-stack web development with ReactJS, NextJS as the frontend and ExpressJS, NestJS-fastify server as the backend**
44

5+
You can clone the full repo and keep only the packages you need in your monorepo, or just retain the source code of a single app, say [express-server](./apps/express-server/) to get started. I'll try my level best to keep all the dependencies in these repos upto date, while also adhering to the industry best practices.
6+
57
## Features
68

79
- [Turborepo](https://turborepo.org/)
810
- [React](https://reactjs.org/), [NestJs](https://nestjs.com/), [ExpressJS](https://expressjs.com/), [NestJS](https://nestjs.com/)
911
- 100% [Typescript](https://www.typescriptlang.org/)
10-
- [Prettier](https://prettier.io/) and Eslint setup alongside `pre-commit` hook.
11-
- [Mui](https://mui.com/) and [Redux](https://redux.js.org/) preconfigured.
12+
- [Prettier](https://prettier.io/) and [Eslint](https://eslint.org/) setup alongside `pre-commit` hook.
13+
- [Mui v6](https://mui.com/) alongside theme change preconfigured.
1214
- [Dockerize](https://docs.docker.com/) images
13-
- Easy to customise
1415
- Github Actions to build apps and publish their docker images
1516

1617
## Get Started

apps/express-server/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ Express JS Application with Typescript
44

55
## Running the app
66

7+
In dev mode,
78
```bash
8-
# development
9-
$ yarn dev
9+
yarn dev
10+
```
1011

11-
# build & run production code
12-
$ yarn prod
12+
Build the app and run production code
13+
```bash
14+
yarn prod
1315
```
1416

1517
### Features
1618

1719
- Express app configured
18-
- Preconfigured logger - [winston](https://www.npmjs.com/package/winston) for logging request and errors
19-
- Producion Dockerfile
20+
- Handled loading of environment variables
21+
- Styled logging using [chalk](https://www.npmjs.com/package/chalk)
22+
- Preconfigured logger middleware - [winston](https://www.npmjs.com/package/winston) for logging request details and errors

apps/express-server/nodemon.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"watch": ["src/"],
3+
"ext": "js,ts,json,yml,yaml",
4+
"ignore": ["*.test.{js,ts}", "node_modules/"]
5+
}

apps/express-server/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
"author": "Nishant Kohli",
55
"private": true,
66
"scripts": {
7-
"dev": "nodemon src/index.ts",
8-
"build": "rimraf dist && tsc",
9-
"start": "ts-node dist/index.js",
7+
"dev": "nodemon --exec 'ts-node -r tsconfig-paths/register src/index.ts'",
8+
"build": "rimraf dist && tsc && tsc-alias",
9+
"start": "node dist/index.js",
1010
"prod": "yarn build && yarn start",
1111
"lint": "eslint --fix ."
1212
},
1313
"dependencies": {
1414
"cors": "^2.8.5",
1515
"dotenv": "^16.4.5",
16-
"express": "^4.19.2",
17-
"winston": "3.13.0"
16+
"express": "^4.21.0",
17+
"winston": "3.15.0"
1818
},
1919
"devDependencies": {
20+
"@nish1896/eslint-config": "^2.0.5",
2021
"@types/cors": "^2.8.17",
21-
"@types/express": "^4.17.21",
22-
"@types/node": "^20.14.9",
22+
"@types/node": "^22.7.4",
2323
"eslint": "^8.57.0",
24-
"nodemon": "^3.1.4",
25-
"rimraf": "^5.0.7",
26-
"ts-node": "^10.9.2",
24+
"nodemon": "^3.1.7",
25+
"rimraf": "^6.0.1",
26+
"tsc-alias": "^1.8.10",
2727
"tsconfig-paths": "^4.2.0",
28-
"typescript": "^5.3.3"
28+
"typescript": "^5.6.2"
2929
}
3030
}

apps/express-server/src/app-constants/env_vars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ const env = process.env;
77

88
export const ENV_VARS = Object.freeze({
99
env: env.NODE_ENV ?? 'development',
10-
port: env.PORT ?? 5000
10+
port: env.PORT ?? 8000
1111
});

apps/express-server/src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import express, { Express, Request, Response } from 'express';
22
import cors from 'cors';
3-
import { ENV_VARS } from 'app-constants';
4-
import { requestLogger } from 'middleware';
5-
import * as Routes from 'routes';
3+
import { ENV_VARS } from '@/app-constants';
4+
import { requestLogger } from '@/middleware';
5+
import * as Routes from '@/routes';
66

77
const app: Express = express();
88

apps/express-server/src/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
/**
2+
* In dev env ts-node will be using tsconfig-paths to
3+
* resolve alias imports.
4+
*
5+
* However when generating the build and running it,
6+
* tsc-alias will replace the alias imports with the
7+
* actual import path relative to each file.
8+
*
9+
* Sadly "node -r tsconfig-paths/register dist/index.js" is
10+
* not resolving the paths when running the build.
11+
*
12+
* "node -r ts-node/register/transpile-only -r tsconfig-paths/register dist/main.js"
13+
* works but not recommended to be used in production because
14+
* of the lack of type safety.
15+
*/
16+
117
import 'dotenv/config';
218
import os from 'os';
319
import { createServer } from 'node:http';
4-
import { ENV_VARS } from 'app-constants';
5-
import { winstonLogger } from 'middleware';
20+
import { ENV_VARS } from '@/app-constants';
21+
import { winstonLogger } from '@/middleware';
622
import app from './app';
723

824
const hostName = os.hostname();

apps/express-server/src/middleware/winston-logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createLogger, addColors, format, transports } from 'winston';
2-
import { ENV_VARS } from 'app-constants';
2+
import { ENV_VARS } from '@/app-constants';
33

44
const { combine, timestamp, printf } = format;
55

apps/express-server/tsconfig.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
{
2-
"extends": "../../tsconfig.json",
32
"compilerOptions": {
4-
"baseUrl": "src",
5-
"rootDir": "src",
6-
"module": "commonjs",
7-
"resolveJsonModule": false,
8-
"outDir": "dist",
3+
"baseUrl": "./",
4+
"outDir": "dist",
5+
"rootDir": "src",
6+
"paths": {
7+
"@/*": ["src/*"]
8+
},
99
"esModuleInterop": true,
10-
"incremental": false
10+
"moduleResolution": "node"
1111
},
12-
"ts-node": {
13-
"require": ["tsconfig-paths/register"]
14-
},
15-
"include": ["src"],
16-
"exclude": ["node_modules", "**/__tests__/*", "dist"]
12+
"include": ["src/**/*.ts"],
13+
"exclude": ["node_modules", "dist"],
14+
"tsc-alias": {
15+
"verbose": false,
16+
"resolveFullPaths": true,
17+
"fileExtensions": {
18+
"inputGlob": "{js,mjs,ts}",
19+
"outputCheck": ["js", "ts", "json", "jsx", "mjs"]
20+
}
21+
}
1722
}

apps/nestjs-server/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
33
</p>
44

5+
6+
### Features
7+
- Routes directory
8+
- Code snippet to switch to `platform-express` or `platform-fastify` (remove the unused platform from package.json)
9+
510
## Running the app
611

712
```bash
@@ -24,8 +29,3 @@ $ yarn run test:e2e
2429
# test coverage
2530
$ yarn run test:cov
2631
```
27-
28-
### Features
29-
30-
- Routes directory
31-
- Dockerfile

0 commit comments

Comments
 (0)