diff --git a/readme.md b/readme.md index 9a821dc..a503c1c 100644 --- a/readme.md +++ b/readme.md @@ -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) -[![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/) +### 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. ---- +### 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 -- 🧩 Built-in `Mongoose` / `Prisma` support -- 📘 Adds Swagger documentation automatically -- 📘 Automatic `Swagger` documentation -- 🔐 `Zod` validation ready -- 🏗️ `Modular` clean architecture -- 🚀 One command project setup -- 🔄 Add modules anytime -- 📦 Zero boilerplate setup +- Docker +- Docker Compose -## 📦 Quick Start +### Authentication -Run directly using npx (recommended): +- JWT -```Bash -npx exp-node-server -c my-api -``` +### Installation -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 -- Install dependencies -- Prepare the project for development +### Environment variables are stored in .env file. They are: +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 : +- 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 -npx express-server-cli -g + npx exp-node-server -g API_NAME (Your api name or folder name) ``` -Example: `npx express-server-cli -g order` - -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 - +### API Structure ``` - -## 📁 Generated Module Structure - -Each module follows a clean structure: - -```Bash -src/app/modules// + src/app/modules// ├── .interface.ts ├── .schema.ts ├── .validation.ts @@ -79,48 +76,4 @@ src/app/modules// ├── .controller.ts ├── .service.ts └── .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. + ``` \ No newline at end of file diff --git a/src/app/modules/order/order.service.ts b/src/app/modules/order/order.service.ts index 864b9ed..8be34f1 100644 --- a/src/app/modules/order/order.service.ts +++ b/src/app/modules/order/order.service.ts @@ -19,54 +19,30 @@ const get_all_order_from_db = async (req: Request) => { const status = (req.query.status as string) || undefined; const { page, limit, skip, sortBy, sortOrder } = paginationHelper(req.query); - const andCondition = [] as any[]; + const andCondition = {} as any; if (search) { - andCondition.push({ - OR: [ - { - productName: { - contains: search, - mode: "insensitive", - }, - }, - ], - }); + andCondition.productName = { + contains: search, + mode: "insensitive", + }; } if (customerName) { - andCondition.push({ - OR: [ - { - customerName: { - contains: customerName, - mode: "insensitive", - }, - }, - ], - }); + andCondition.customerName = { + contains: customerName, + mode: "insensitive", + }; } if (productName) { - andCondition.push({ - OR: [ - { - productName: { - contains: productName, - mode: "insensitive", - }, - }, - ], - }); + andCondition.productName = { + contains: productName, + mode: "insensitive", + }; } if (status) { - andCondition.push({ - OR: [ - { - status: { - contains: status, - mode: "insensitive", - }, - }, - ], - }); + andCondition.status = { + contains: status, + mode: "insensitive", + }; } // for date filter @@ -82,17 +58,13 @@ const get_all_order_from_db = async (req: Request) => { dateFilter.lte = end; } if (Object.keys(dateFilter).length > 0) { - andCondition.push({ - createdAt: dateFilter, - }); + andCondition.createdAt = dateFilter; } const getAllOrders = await prisma.order.findMany({ take: limit, skip, - where: { - AND: andCondition, - }, + where: andCondition, select: { id: 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 payload = req?.body; - + payload.status = "INITIATED"; payload.paymentType = "COD"; diff --git a/src/app/modules/order/order.swagger.ts b/src/app/modules/order/order.swagger.ts index f4d705c..b281705 100644 --- a/src/app/modules/order/order.swagger.ts +++ b/src/app/modules/order/order.swagger.ts @@ -121,7 +121,7 @@ export const orderSwaggerDocs = { patch: { tags: ["order"], summary: "Update order -(Admin route)", - description: "", + description: "The status can be updated to any of the following values : INITIATED,CONFIRMED,ONGOING,DELIVERED,CANCELLED", parameters: [ { name: "id", diff --git a/src/app/modules/order/order.validation.ts b/src/app/modules/order/order.validation.ts index e3a08aa..9b23609 100644 --- a/src/app/modules/order/order.validation.ts +++ b/src/app/modules/order/order.validation.ts @@ -13,7 +13,7 @@ const create_order = z.object({ customerNote: z.string().optional() }); const update_order = z.object({ - status: z.string().optional() + status: z.enum(["INITIATED","CONFIRMED","ONGOING","DELIVERED","CANCELLED"]).optional() }); export const order_validations = {