Backend developed in Node.js + TypeScript implementing JWT authentication, role control, and management of users, clients, products, warehouses, and delivery orders.
It uses Sequelize with PostgreSQL as the main database and is fully prepared to run in Docker.
- Node.js + Express.js β Server framework.
- TypeScript β Static typing.
- Sequelize (PostgreSQL) β ORM for database handling.
- bcryptjs β Password encryption.
- jsonwebtoken (JWT) β Authentication and authorization.
- dotenv β Environment variables.
- Nodemon β Auto-reload in development.
- CORS β HTTP access control.
- ESLint + Prettier β Code linting and formatting.
- Docker + Docker Compose β Project containerization.
Clone the repository and enter the directory:
git clone https://github.com/DavidZapata1312/fhl.git
cd fhlInstall dependencies:
npm installnpm install express sequelize pg pg-hstore bcryptjs jsonwebtoken dotenv corsnpm install -D typescript ts-node nodemon @types/express @types/node @types/bcryptjs @types/jsonwebtoken @types/cors eslint prettier eslint-config-prettier eslint-plugin-prettier| Command | Description |
|---|---|
npm run dev |
Starts the server in development mode with Nodemon |
npm run build |
Compiles TypeScript to JavaScript (dist/ folder) |
npm start |
Runs the compiled version |
npm run lint |
Runs ESLint and Prettier analysis |
src/
βββ config/
β βββ db.ts # Sequelize (PostgreSQL) configuration
β
βββ controllers/
β βββ user.controller.ts
β βββ client.controller.ts
β βββ product.controller.ts
β βββ bodega.controller.ts
β βββ delivery.controller.ts
β
βββ middleware/
β βββ auth.ts # JWT middleware
β βββ rolVerification.ts # Role-based verification middleware
β
βββ models/
β βββ user.model.ts
β βββ client.model.ts
β βββ product.model.ts
β βββ bodega.model.ts
β βββ delivery.model.ts
β βββ associations.ts
β
βββ routes/
β βββ user.routes.ts
β βββ client.routes.ts
β βββ product.routes.ts
β βββ bodega.routes.ts
β βββ delivery.routes.ts
β
βββ services/
β βββ user.service.ts
β βββ client.service.ts
β βββ product.service.ts
β βββ bodega.service.ts
β βββ delivery.service.ts
β
βββ seed/
β βββ seed.ts # Initial data seeding
β
βββ app.ts # Express main configuration
βββ server.ts # Entry point
Create a .env file in the root directory with:
PORT=3000
JWT_SECRET=supersecret
DB_NAME=fhl_db
DB_USER=david
DB_PASSWORD=perla
DB_HOST=localhost
DB_PORT=5432
docker-compose up --builddocker-compose downService available at: π http://localhost:3000
A Postman collection is included with full CRUD routes for:
/authβ JWT login/usersβ User management (admin only)/clientsβ Clients/productsβ Products/bodegasβ Warehouses/deliveriesβ Delivery orders
You can import the collection from the /postman folder.
Recommended Variables:
DB_USER=david
DB_PASSWORD=perla
DB_NAME=fhl_database
DB_HOST=postgres
DB_PORT=5432
JWT_SECRET=mi_super_secreta_clave_1234
Run the initial seed with:
npx ts-node src/seed/seed.tsThis will create example users, products, clients, and bodegas.
- ESLint
- Prettier
- Docker
- REST Client or Postman
Project licensed under MIT License.
Created with β€οΈ by David Zapata, Linus
Backend architecture for the logistics management platform (FHL).