A REST API built with Express.js and TypeScript with JWT-based authentication.
- User CRUD
- Authentication using JWT
- Brazilian CPF, phone, and email validation
- Password encryption
- Error handling with
neverthrow
- PostgreSQL database with Prisma ORM
- Docker support
- Node.js 18+
- PostgreSQL 15
- Yarn
- (Optional) Docker
- Clone the repository:
git clone <github.com/leeozaka/cachorrinho-express>
cd <cachorrinho-express>
- Install dependencies:
yarn install
- Create a
.env
file based on .env.example
and configure your environment variables:
DATABASE_URL="postgresql://salvacao:salvacao123@localhost:5432/cachorrinhodb"
JWT_SECRET=your-secret-key
PORT=3344
- Generate Prisma client:
npx prisma generate
docker-compose up
- Start the dev server:
yarn dev
- App runs at
http://localhost:3344
.
POST /user
(create user)GET /user
(find user byreq.body.userId
or?id=
)PUT /user
(update user)DELETE /user
(soft-delete user)
POST /login
(authenticate user)
POST /login
- User login
src/
├── @types/ # Type definitions
├── config/ # Configuration files
├── controllers/ # Route controllers
├── dtos/ # Data Transfer Objects
├── enums/ # Enumerations
├── helpers/ # Helper functions
├── interfaces/ # TypeScript interfaces
├── mapper/ # Object mappers
├── middlewares/ # Express middlewares
├── models/ # Domain models
├── prisma/ # Database schema and migrations
├── repositories/ # Data access layer
├── routes/ # Route definitions
├── services/ # Business logic
├── tests/ # Test files
└── utils/ # Utility functions
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This README provides a comprehensive overview of the project structure, setup instructions, available endpoints, and contribution guidelines based on the codebase. The structure reflects the actual organization of your project and includes the key features implemented in your code.
You can add more sections as needed, such as:
- Detailed API documentation
- Environment variable descriptions
- Deployment instructions
- Troubleshooting guide
- Performance considerations
- Security recommendations