An open API service indexing awesome lists of open source software.

https://github.com/nazmul-nhb/test-school-server

Server for Test School
https://github.com/nazmul-nhb/test-school-server

assesment express lms mongoose nhb-express nhb-scripts nhb-toolbox school server test typescript

Last synced: 29 days ago
JSON representation

Server for Test School

Awesome Lists containing this project

README

          

# πŸš€ Express TypeScript Mongoose Server

Bootstrapped with [**nhb-express**](https://www.npmjs.com/package/nhb-express)

---

## πŸ“¦ Features

- βœ… **TypeScript** with `ts-node` and `nodemon` for development and pre-configured `tsconfig.json`
- βœ… **Express.js** pre‑configured with custom middlewares
- βœ… **Zod** for schema validation
- βœ… **Mongoose** for MongoDB integration
- βœ… **Chalk** for colorful logging
- βœ… **[nhb-scripts](https://www.npmjs.com/package/nhb-scripts)** for easy build, commit, module scaffolding, formatting, linting, and more. [see below](#️-scripts)
- βœ… **Scaffolding via CLI** – choose package manager, DB, etc.
- βœ… Built‑in [**CI/CD workflow**](#️-cicd-workflow) for automatic deployment to Vercel
- βœ… Pre‑set configs for ESLint, Prettier, and `nhb-scripts`

---

## πŸš€ Development

Install dependencies (already done by `nhb-express` scaffold)

Run in development mode:

```bash
pnpm dev # or npm run dev / yarn dev
# Runs on port: 4242
```

---

## πŸ“ Structure

```text
/
β”œβ”€ .github/
β”‚ └─ workflows/
β”‚ └─ publish.yml # GitHub Actions workflow for CI/CD (vercel deployment)
β”œβ”€ .vscode/
β”‚ └─ settings.json # VS Code Settings for better formatting
β”œβ”€ src/
β”‚ |─ app/
β”‚ | β”œβ”€ classes/ # Utility classes e.g. `QueryBuilder`, `ErrorWihStatus`
β”‚ | β”œβ”€ configs/ # App configurations
β”‚ | β”œβ”€ constants/ # Constant values
β”‚ | β”œβ”€ errors/ # Custom error processors/handlers
β”‚ | β”œβ”€ middlewares/ # Custom Express middlewares
β”‚ | β”œβ”€ modules/ # Feature modules (controllers, services, etc.)
β”‚ | β”œβ”€ routes/ # Route definitions
β”‚ | β”œβ”€ types/ # Types for the App
β”‚ | └─ utilities/ # Helper functions
β”‚ |
β”‚ β”œβ”€ app.ts # Express app setup
β”‚ β”œβ”€ index.d.ts # Global type declarations
β”‚ └─ server.ts # Server bootstrap
β”‚
β”œβ”€ .env # Environment variables
β”œβ”€ .gitignore # Ignore files/folders from being pushed/committed
β”œβ”€ .prettierignore # Ignore files/folders from being formatted with prettier
β”œβ”€ .prettierrc.json # Prettier config
β”œβ”€ eslint.config.mjs # ESLint config (flat config, ready for TS)
β”œβ”€ nhb.scripts.config.mjs # Config for nhb-scripts
β”œβ”€ nodemon.json # Nodemon settings
β”œβ”€ package.json
β”œβ”€ README.md
β”œβ”€ secret.mjs # Generate secrets for jwt (using crypto module, just run in cli: node secret.mjs or pnpm/npm/yarn run secret)
β”œβ”€ tsconfig.json # Ready to use tsconfig
└─ vercel.json # Deployment config for Vercel
```

---

## πŸ› οΈ Scripts

- `pnpm dev` – Start in dev mode with hot reload
- `pnpm start` – Run the built server
- `pnpm deploy` – Build the project and deploy to Vercel (`nhb-build && vercel --prod`)
- `pnpm build` – Build the project for production (`nhb-build`)
- `pnpm format` – Format the codebase (`nhb-format`)
- `pnpm lint` – Lint the code (`nhb-lint`)
- `pnpm fix` – Auto‑fix lint issues (`nhb-fix`)
- `pnpm commit` – Guided commit workflow (`nhb-commit`)
- `pnpm count` – Count exports (`nhb-count`)
- `pnpm module` – Scaffold new modules (`nhb-module`)

---

## βš™οΈ CI/CD Workflow

A ready‑to‑use **GitHub Actions workflow** is included in:

```text
.github/workflows/publish.yml
```

βœ… **What it does:**

- Runs on push to your main branch
- Builds your project
- Deploys automatically to **Vercel** (configured via `vercel.json`)

βœ… **How to use:**

1. Push your project to a GitHub repository.
2. Add your Vercel tokens/secrets as GitHub repository secrets:
Go to `Settings >> Secrets and variables >> Actions >> Repository secrets` and add these variables:
- `VERCEL_ORG_ID`
- `VERCEL_PROJECT_ID`
- `VERCEL_TOKEN`
3. Every time you push to `main` and _version is updated_, GitHub Actions will trigger and deploy your server to Vercel.

You can customize the workflow to fit your own CI/CD needs (e.g., change branches, add tests, deploy elsewhere).

---

Made with ❀️ by [Nazmul Hassan](https://github.com/nazmul-nhb)

**Powered by `nhb-express`** πŸš€