Skip to content

Commit

Permalink
refactor: Refactor the binding of container to the App class and upda…
Browse files Browse the repository at this point in the history
…ted various sections by this effect

Remove inporting container in app, injected controllers instances to the app, made the model injectable, modify repository, services and controllers, updated user model, imp
lemented zod validation schema
  • Loading branch information
AllStackDev1 committed Aug 1, 2024
1 parent 4ed3fb0 commit f6d2d8b
Show file tree
Hide file tree
Showing 41 changed files with 1,334 additions and 319 deletions.
14 changes: 14 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PORT=8000
HOSTNAME=localhost

DB_PORT=5432
DB_NAME=nodejs-sequelized
DB_HOST=localhost
DB_USERNAME=MrCEO
DB_PASSWORD=

REDIS_URL=redis://localhost:6379

SESSION_SECRET=^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[@$!%*?&])[A-Za-zd@$!%*?&]{8,}$

HASHING_SALT=12
14 changes: 14 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PORT=8000
HOSTNAME=localhost

DB_PORT=5432
DB_NAME=nodejs-sequelized
DB_HOST=localhost
DB_USERNAME=MrCEO
DB_PASSWORD=

REDIS_URL=redis://localhost:6379

SESSION_SECRET=^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[@$!%*?&])[A-Za-zd@$!%*?&]{8,}$

HASHING_SALT=12
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
node_modules
.env
build
build
coverage
react-email-starter
.babelrc
tests/
events/
jest.config.ts
11 changes: 10 additions & 1 deletion env.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
declare global {
namespace NodeJS {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface ProcessEnv {
NODE_ENV: 'development' | 'production' | 'test';

PORT?: string;
HOSTNAME: string;

DB_HOST: string;
DB_PORT: string;
DB_NAME: string;
DB_USERNAME: string;
DB_PASSWORD: string;

REDIS_URL: string;

SESSION_SECRET: string;

HASHING_SALT: string;

// Add other environment variables here
}
}
Expand Down
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"description": "learning",
"main": "src/server.ts",
"scripts": {
"dev": "nodemon -r tsconfig-paths/register ./src/server.ts",
"start": "TS_NODE_BASEURL=./build nodemon -r tsconfig-paths/register ./build/server.js",
"dev": "NODE_ENV=development nodemon -r tsconfig-paths/register ./src/server.ts",
"start": "NODE_ENV=development TS_NODE_BASEURL=./build nodemon -r tsconfig-paths/register ./build/server.js",
"build": "rimraf build && tsc -p ./tsconfig.build.json",
"db:create": "pnpm run build && npx sequelize-cli db:create",
"db:migrate:up": "pnpm run build && npx sequelize-cli db:migrate",
"db:migrate:undo": "pnpm run build && npx sequelize-cli db:migrate:undo",
"test": "jest",
"db:create": "pnpm run build && NODE_ENV=development npx sequelize-cli db:create",
"db:migrate:up": "pnpm run build && NODE_ENV=development npx sequelize-cli db:migrate",
"db:migrate:undo": "pnpm run build && NODE_ENV=development npx sequelize-cli db:migrate:undo",
"lint": "eslint --ignore-path .eslintignore --ext .js,.ts"
},
"author": "Chinedu",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.1",
"connect-redis": "^7.1.1",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand All @@ -26,6 +26,7 @@
"inversify": "^6.0.2",
"ioredis": "^5.4.1",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.14",
"pg": "^8.12.0",
"pg-hstore": "^2.3.4",
"rate-limiter-flexible": "^5.0.3",
Expand All @@ -35,11 +36,16 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@babel/preset-typescript": "^7.24.7",
"@eslint/js": "^10.0.0",
"@tsconfig/node16": "^16.1.3",
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.21",
"@types/express-session": "^1.18.0",
"@types/node": "^20.14.10",
"@types/jest": "^29.5.12",
"@types/node": "^22.0.0",
"@types/safe-regex": "^1.1.6",
"@types/supertest": "^6.0.2",
"@types/validator": "^13.12.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
Expand All @@ -48,10 +54,13 @@
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.8.0",
"jest": "^29.7.0",
"nock": "^13.5.4",
"nodemon": "^3.1.4",
"prettier": "3.3.3",
"rimraf": "^6.0.1",
"sequelize-cli": "^6.6.2",
"supertest": "^7.0.0",
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.5.3",
Expand Down
Loading

0 comments on commit f6d2d8b

Please sign in to comment.