Skip to content

ashusnp/node-test-ashish-sanap

Repository files navigation

Weather App 🌦️

A Node.js application built with Express, Prisma ORM, and PostgreSQL.
It includes modern tooling such as ESLint, Prettier, Husky, and lint-staged for consistent code quality, plus logging with Winston and Morgan.


🚀 Features

  • Express-based REST API
  • Prisma ORM with PostgreSQL
  • JWT authentication
  • Request validation using express-validator
  • Centralized error handling
  • Logging with Winston + Morgan
  • ESLint + Prettier integration
  • Husky hooks for pre-commit and pre-push
  • Babel for transpiling

🛠️ Prerequisites

  • Node.js v20+
  • PostgreSQL (or NeonDB, as in .env)
  • npm or yarn

📦 Installation

  1. Clone the repository

    git clone https://github.com/ashusnp/node-test-ashish-sanap.git
    cd node-test-ashish-sanap
  2. Install dependencies npm install

  3. Setup environment variables Create a .env file in the root directory (see sample.env for reference): NODE_ENV=development PORT=3000 DB_URL="postgresql://:@/?sslmode=require" JWT_SECRET=your-jwt-secret OPEN_WEATHER_API_KEY=your-api-key OPEN_WEATHER_MAP_URL=https://api.openweathermap.org/data/2.5 SERVICE_NAME=weather-app ORIGIN=http://localhost:3000

  4. 🗄️ Database (Prism)a Generate Prisma Client npx prisma generate Run migrations npx prisma migrate dev --name init Open Prisma Studio (GUI) npx prisma studio

🧑‍💻 Running the App Development npm run dev Development (start only)

npm run dev-start Production (with build)

npm run dev-prod Production (direct) npm run prod 📜 Scripts Overview npm run dev → Start app with nodemon (auto-restarts on save)

npm run start → Run app normally with Babel

npm run build → Transpile code into /build

npm run prod → Run production build

npm run lint → Run ESLint

npm run lint-fix → Fix lint issues

npm run pretty → Run Prettier formatter

npm run swagger-autogen → Generate Swagger docs

npm run clean → Remove build artifacts

🧹 Code Quality (Lint & Prettier) ESLint + Prettier enforce consistent coding style.

Husky + lint-staged run checks before committing:

pre-commit → runs prettier + eslint

pre-push → runs eslint

Manually: npm run lint npm run lint-fix npm run pretty

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published