{"id":18708970,"url":"https://github.com/baguilar6174/node-natours-server","last_synced_at":"2025-04-12T10:34:59.190Z","repository":{"id":179317228,"uuid":"662762875","full_name":"baguilar6174/node-natours-server","owner":"baguilar6174","description":"This repository contains a Rest API server created with Node, Express and Typescript, using clean architecture and best development practices. It uses MongoDB DB.","archived":false,"fork":false,"pushed_at":"2024-11-06T21:34:01.000Z","size":10625,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T05:41:53.660Z","etag":null,"topics":["docker","docker-compose","eslint","express","hexagonal-architecture","mongo","mongoose","node","prettier","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baguilar6174.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-05T20:49:11.000Z","updated_at":"2024-11-06T21:34:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f2be097-cfb8-428c-834a-6a2ef04d6b14","html_url":"https://github.com/baguilar6174/node-natours-server","commit_stats":null,"previous_names":["baguilar6174/node-natours-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baguilar6174%2Fnode-natours-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baguilar6174%2Fnode-natours-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baguilar6174%2Fnode-natours-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baguilar6174%2Fnode-natours-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baguilar6174","download_url":"https://codeload.github.com/baguilar6174/node-natours-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248553818,"owners_count":21123525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","eslint","express","hexagonal-architecture","mongo","mongoose","node","prettier","typescript"],"created_at":"2024-11-07T12:25:51.344Z","updated_at":"2025-04-12T10:34:58.738Z","avatar_url":"https://github.com/baguilar6174.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Natours Server\n\nThis repository contains a Rest API server created with Node, Express and Typescript, using clean architecture and best development practices. It uses MongoDB DB.\n\n## Hexagonal Architecture (Ports \u0026 Adapters) and DDD\n\nThe hexagonal architecture seeks to separate the business logic from the user interface and in turn from the external infrastructure. To do so, we divide the application into three main layers:\n\n### Domain\n\nA layer that is the most internal of all, (core of the application). Here are the essential components and modules that execute the main functions of the software. This central part is responsible for coordinating and managing the interactions between the various layers and elements of the system, ensuring efficiency, scalability and stability of the application.\n\n**Important**: in this layer, the logic of the necigio is defined (DEFINITION != IMPLEMENTATION)\n\n### Application\n\nIt is the one that contains the implementation of the services and the business logic.\n\n### Infraestructure\n\nIt is the most external layer of all, where it connects with external applications, databases, API Rest, etc.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\" valign=\"center\"\u003e\u003cimg src=\"./media/hexagonal_architecture.jpeg\" width=\"50%\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n**Important**: The innermost layers cannot depend on external layers (dependency inversion principle). In other words, the domain layer cannot depend on any other layer. In turn, the application layer cannot depend on the infrastructure layer and must only communicate with the domain layer through ports.\n\n- **Ports**: are used as communication bridges between the different layers of the application.\n- **Adapters**: are used as external communication bridges for the application (other applications, external services, etc.). The adapters are located in the infrastructure layer.\n\n**You can read more about this implementation in [docs folder](./docs/)**\n\n## Installation\n\nThis project was generated with [Express](https://expressjs.com/)\n\nClone this repository\n\n```bash\ngit clone https://github.com/baguilar6174/node-natours-server.git\n```\n\nInstall dependencies\n\n```bash\nyarn\n```\n\n## Running the app\n\nIf you need local mongo database\n\n- Install docker\n- Run `docker-compose up -d` This command create a local volumen in root project to save data.\n\n**Important**: If you don't need mongo from Docker or if you decide to use some different email client, set your configuration into `.env` file. Mi `docker-compose.yaml` create two containers:\n\n1. **Mongo Database**: the volume of this database is allocated in the root of your project `./mongo` if you delete this folder you'll lose your data.\n2. **Mailhog Server**: this client allow you to send emails in to local machine. You can view the email inbox at [http://localhost:8025/](http://localhost:8025/)\n\n- Rename `.env.template` to `.env` and add your environment variables\n- Run `yarn dev`\n\nIf your want to create build production, run `yarn build`\n\n## My process\n\n### Built with\n\n- Node\n- Express\n- Typescript\n- MongoDB \u0026 Mongoose\n- Eslint \u0026 Prettier\n\n### What I learned\n\n- Fundamentals of Express (Node.js framework): routing, middleware, sending responses, etc.\n- RESTful API design and development with advanced features: filtering, sorting, aliasing, pagination\n- CRUD operations with MongoDB and Mongoose\n- Fundamentals of Mongoose (MongoDB JS driver): Data models, CRUD operations, data validation, and middleware\n- Using clean architecture\n- How to work with data in NoSQL databases\n- Use Mongo pipelines\n- How to work with data in NoSQL databases (including geospatial data)\n- Security: encryption, sanitization, rate limiting, etc.\n- Complete modern authentication and authorization with JWT: user sign up, log in, password reset, secure cookies, etc.\n\n## Development Features\n\n- Clean Architecture\n- Eslint and Prettier\n- Good folder structure\n- Complete authentication and authorization module\n- Authorization (user roles)\n- Security: best practices, encryption, sanitization, rate limiting, etc.\n\n## Improves\n\n- Using repository pattern\n- Using object value pattern\n- Implements SQL repository\n- Include real email client\n- Implements a web client to consume this API\n- Implement advanced authentication features\n  - Confirm user email\n  - Keep user logged in with refresh tokens\n  - 2FA\n\n## TODO:\n\n- Make responses with same format\n- API Documentation\n- Alias path\n- Verify mailhog with docker compose\n- Endpoint to delete and create fake data\n- Select neccesary field into relationships\n- Remove validation where route uses protect middleware\n- Add CORS config\n\n## Natours Server\n\n### Postman Collection\n\nYou can see all endpoints in this collection [postman_collection](./docs/postman_collection.json) and the environment variables [postman_environment](./docs/postman_environment.json)\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\" valign=\"center\"\u003e\u003cimg src=\"./media/data_model.png\" width=\"100%\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Stay in touch\n\n- Website - [www.bryan-aguilar.com](https://www.bryan-aguilar.com/)\n- Medium - [baguilar6174](https://baguilar6174.medium.com/)\n- LinkedIn - [baguilar6174](https://www.linkedin.com/in/baguilar6174)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaguilar6174%2Fnode-natours-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaguilar6174%2Fnode-natours-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaguilar6174%2Fnode-natours-server/lists"}