Bug/db update#6 #13

Merged
abumahid merged 2 commits from bug/db-update#6 into main 2026-06-18 04:46:47 +00:00
4 changed files with 75 additions and 150 deletions
+53 -100
View File
@@ -1,77 +1,74 @@
# ⚡ Express Server CLI # QuickLaunch Server
[![npm version](https://img.shields.io/npm/v/exp-node-server.svg)](https://www.npmjs.com/package/exp-node-server) ### This server is a nodejs server with express framework. It provides a REST API for quicklunch app. It is written in typescript and uses prisma for database.It is deployed on docker and is managed by docker compose.
[![npm downloads](https://img.shields.io/npm/dw/exp-node-server.svg)](https://www.npmjs.com/package/exp-node-server)
[![npm total downloads](https://img.shields.io/npm/dt/exp-node-server.svg)](https://www.npmjs.com/package/exp-node-server)
[![Made with TypeScript](https://img.shields.io/badge/Made%20with-TypeScript-blue.svg)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-18+-green.svg)](https://nodejs.org/)
--- ### Features
## 🚀 Overview - Authentication
- Authorization
- Database Management
- REST API
- Testing
- Deployment
A powerful `Express + TypeScript CLI` that instantly generates scalable `backend` modules with `Mongoose `/ `Prisma`, `Zod` `validation`, and `Swagger` documentation. ### Technologies
This tool helps developers quickly scaffold `clean`, `modular` `Express` APIs with minimal setup. - Nodejs
- Express
- Typescript
- Prisma
- Docker
- Docker Compose
- Bullmq
-Nodemailer
## ✨ Features ### Deployment
- ⚡ Generate complete `Express` + `TypeScript` modules - Docker
- 🧩 Built-in `Mongoose` / `Prisma` support - Docker Compose
- 📘 Adds Swagger documentation automatically
- 📘 Automatic `Swagger` documentation
- 🔐 `Zod` validation ready
- 🏗️ `Modular` clean architecture
- 🚀 One command project setup
- 🔄 Add modules anytime
- 📦 Zero boilerplate setup
## 📦 Quick Start ### Authentication
Run directly using npx (recommended): - JWT
```Bash ### Installation
npx exp-node-server -c my-api
```
This will: - git clone git@codelab.techzaa.tech:summer2026/quicklanch-server.git
- cd quicklunch-server
- npm install
- npm run dev
- Create an Express starter project ### Environment variables are stored in .env file. They are:
- Install dependencies Set up or add the following environment variables in .env file to run the server. You will copy and paste them from the .env.example file by adding Database URL,APP USER EMAIL, APP PASSWORD, CLOUD NAME, CLOUD API KEY, CLOUD API SECRET and REDIS URL :
- Prepare the project for development - PORT = 5000
- DATABASE_URL
-ACCESS_TOKEN=8b8ba26578276a8bf9d0599f8c0ec0d2d69e0aec9171e989a314c36db0b330a23fd0365a6c9b1059406856046e28dc0e13c9d6a165e2936e6614aa2d1862af68
- ACCESS_EXPIRES=24h
- RESET_SECRET=8b8ba26578276a8bf9d0599f8c0ec0d2d69e0aec9171e989a314c36db0b330a23fd0365a6c9b1059406856046e28dc0e13c9d6a165e2936e6614aa2d1862af68
- RESET_EXPIRES=5m
- VERIFIED_TOKEN=8b8ba26578276a8bf9d0599f8c0ec0d2d69e0aec9171e989a314c36db0b330a23fd0365a6c9b1059406856046e28dc0e13c9d6a165e2936e6614aa2d1862af68
- FRONT_END_URL=http://localhost:5173/
- APP_USER_EMAIL
- APP_PASSWORD
- CLOUD_NAME
- CLOUD_API_KEY
- CLOUD_API_SECRET
- REDIS_URL
## 🧩 Generate a Module ### API Documentation
Inside your project run: - API documentation is available at http://localhost:5000/api-docs
### API Creating
If you need to create an new api you will only run simple command the command is
```bash ```bash
npx express-server-cli -g <module-name> npx exp-node-server -g API_NAME (Your api name or folder name)
``` ```
Example: `npx express-server-cli -g order` ### API Structure
Output:
```Bash
✔ order.interface.ts created
✔ order.schema.ts created
✔ order.validation.ts created
✔ order.route.ts created
✔ order.controller.ts created
✔ order.service.ts created
✔ order.swagger.ts created
🔗 Route registered in routes.ts
📘 Swagger docs registered
``` ```
src/app/modules/<module-name>/
## 📁 Generated Module Structure
Each module follows a clean structure:
```Bash
src/app/modules/<module-name>/
├── <module>.interface.ts ├── <module>.interface.ts
├── <module>.schema.ts ├── <module>.schema.ts
├── <module>.validation.ts ├── <module>.validation.ts
@@ -79,48 +76,4 @@ src/app/modules/<module-name>/
├── <module>.controller.ts ├── <module>.controller.ts
├── <module>.service.ts ├── <module>.service.ts
└── <module>.swagger.ts └── <module>.swagger.ts
``` ```
## ⚙️ Run the Project
```bash
npm run dev
```
Swagger docs available at:
```bash
http://localhost:5000/docs
```
## 🧠 Tech Stack
- Express.js — Backend framework
- TypeScript — Strongly typed JavaScript
- Mongoose — MongoDB ODM
- Prisma — PostgreSQL ORM
- Zod — Runtime schema validation
- JWT — Authentication
- Swagger — API documentation
## 👨‍💻 Author
### Abumahid
GitHub
https://github.com/dev-abumahid
npm
https://www.npmjs.com/~dev_abumahid
Portfolio
https://abumahid.me
LinkedIn
https://linkedin.com/in/md-abu-mahid-islam
## ⭐ Support
If you find this project helpful, consider giving it a ⭐ on `GitHub`.
It helps the project grow and reach more developers.
+20 -48
View File
@@ -19,54 +19,30 @@ const get_all_order_from_db = async (req: Request) => {
const status = (req.query.status as string) || undefined; const status = (req.query.status as string) || undefined;
const { page, limit, skip, sortBy, sortOrder } = paginationHelper(req.query); const { page, limit, skip, sortBy, sortOrder } = paginationHelper(req.query);
const andCondition = [] as any[]; const andCondition = {} as any;
if (search) { if (search) {
andCondition.push({ andCondition.productName = {
OR: [ contains: search,
{ mode: "insensitive",
productName: { };
contains: search,
mode: "insensitive",
},
},
],
});
} }
if (customerName) { if (customerName) {
andCondition.push({ andCondition.customerName = {
OR: [ contains: customerName,
{ mode: "insensitive",
customerName: { };
contains: customerName,
mode: "insensitive",
},
},
],
});
} }
if (productName) { if (productName) {
andCondition.push({ andCondition.productName = {
OR: [ contains: productName,
{ mode: "insensitive",
productName: { };
contains: productName,
mode: "insensitive",
},
},
],
});
} }
if (status) { if (status) {
andCondition.push({ andCondition.status = {
OR: [ contains: status,
{ mode: "insensitive",
status: { };
contains: status,
mode: "insensitive",
},
},
],
});
} }
// for date filter // for date filter
@@ -82,17 +58,13 @@ const get_all_order_from_db = async (req: Request) => {
dateFilter.lte = end; dateFilter.lte = end;
} }
if (Object.keys(dateFilter).length > 0) { if (Object.keys(dateFilter).length > 0) {
andCondition.push({ andCondition.createdAt = dateFilter;
createdAt: dateFilter,
});
} }
const getAllOrders = await prisma.order.findMany({ const getAllOrders = await prisma.order.findMany({
take: limit, take: limit,
skip, skip,
where: { where: andCondition,
AND: andCondition,
},
select: { select: {
id: true, id: true,
customerName: true, customerName: true,
@@ -130,7 +102,7 @@ const get_single_order_from_db = async (req: Request) => {
const create_order_into_db = async (req: Request) => { const create_order_into_db = async (req: Request) => {
const payload = req?.body; const payload = req?.body;
payload.status = "INITIATED"; payload.status = "INITIATED";
payload.paymentType = "COD"; payload.paymentType = "COD";
+1 -1
View File
@@ -121,7 +121,7 @@ export const orderSwaggerDocs = {
patch: { patch: {
tags: ["order"], tags: ["order"],
summary: "Update order -(Admin route)", summary: "Update order -(Admin route)",
description: "", description: "The status can be updated to any of the following values : INITIATED,CONFIRMED,ONGOING,DELIVERED,CANCELLED",
parameters: [ parameters: [
{ {
name: "id", name: "id",
+1 -1
View File
@@ -13,7 +13,7 @@ const create_order = z.object({
customerNote: z.string().optional() customerNote: z.string().optional()
}); });
const update_order = z.object({ const update_order = z.object({
status: z.string().optional() status: z.enum(["INITIATED","CONFIRMED","ONGOING","DELIVERED","CANCELLED"]).optional()
}); });
export const order_validations = { export const order_validations = {