{"id":26704991,"url":"https://github.com/floriangolling/backend_typescript_template","last_synced_at":"2026-04-12T14:52:58.099Z","repository":{"id":284597306,"uuid":"955427564","full_name":"floriangolling/backend_typescript_template","owner":"floriangolling","description":"Backend Typescript Template","archived":false,"fork":false,"pushed_at":"2025-03-26T17:07:24.000Z","size":640,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T18:24:24.110Z","etag":null,"topics":["api","api-rest","cicd","database","docker","docker-compose","express","jest","jest-tests","jwt","lint","migrations","mocha","mocha-tests","nodejs","postgresql","sequelize","swagger","tests","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/floriangolling.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":"2025-03-26T16:11:27.000Z","updated_at":"2025-03-26T17:13:31.000Z","dependencies_parsed_at":"2025-03-26T18:34:40.362Z","dependency_job_id":null,"html_url":"https://github.com/floriangolling/backend_typescript_template","commit_stats":null,"previous_names":["floriangolling/backend_ts_template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangolling%2Fbackend_typescript_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangolling%2Fbackend_typescript_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangolling%2Fbackend_typescript_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floriangolling%2Fbackend_typescript_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floriangolling","download_url":"https://codeload.github.com/floriangolling/backend_typescript_template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245785806,"owners_count":20671634,"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":["api","api-rest","cicd","database","docker","docker-compose","express","jest","jest-tests","jwt","lint","migrations","mocha","mocha-tests","nodejs","postgresql","sequelize","swagger","tests","typescript"],"created_at":"2025-03-27T05:20:22.302Z","updated_at":"2026-04-12T14:52:58.094Z","avatar_url":"https://github.com/floriangolling.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backend_typescript_template\n\n![Badges](server/coverage/badges.svg)\n\nThis is a TypeScript-based backend template that follows best practices for building scalable and maintainable applications. It uses a **Model-Controller-Service-Routes** architecture for clean separation of concerns and provides development and testing scripts to streamline your workflow.\nIt is currently working as a Todo API\n\n## Requirements\n\n- Node.js (version specified in `.nvmrc`)\n\n## Scripts\n\n### Database Setup\n- **`database.dev.sh`**: Launches a Dockerized database for development purposes.\n- **`database.test.sh`**: Launches a Dockerized database for testing purposes.\n  \n  These scripts should be run once and will run in the background, enabling your app to interact with the database.\n\n### Available NPM Scripts\n\n- **`lint`**: Runs the linter to check for code style issues and errors using Biome.\n  ```bash\n  npm run lint\n  ```\n\n- **`lint:fix`**: Automatically fixes code style issues using Biome.\n  ```bash\n  npm run lint:fix\n  ```\n\n- **`lint:fix-unsafe`**: Force fixes code style issues, even if they may be unsafe (use with caution).\n  ```bash\n  npm run lint:fix-unsafe\n  ```\n\n- **`db:migrate`**: Runs the database migrations.\n  \n  You can specify one of the following actions:\n  - **`up`**: Applies all pending migrations.\n    ```bash\n    npm run db:migrate up\n    ```\n  - **`down`**: Reverts the last applied migration.\n    ```bash\n    npm run db:migrate down\n    ```\n  - **`create`**: Creates a new migration file.\n    ```bash\n    npm run db:migrate create [filename]\n    ```\n\n- **`start`**: Builds the app, runs database migrations, and starts the application.\n  ```bash\n  npm run start\n  ```\n\n- **`build`**: Compiles TypeScript code and resolves path aliases.\n  ```bash\n  npm run build\n  ```\n\n- **`test`**: Runs tests with Mocha in a test environment, migrating the database beforehand.\n  ```bash\n  npm run test\n  ```\n\n- **`test:coverage`**: Runs tests with coverage tracking enabled, using NYC for reporting.\n  ```bash\n  npm run test:coverage\n  ```\n\n- **`coverage-badge`**: Generates a coverage badge for your project.\n  ```bash\n  npm run coverage-badge\n  ```\n\n- **`dev`**: Runs the application in development mode with automatic restarts using `nodemon`.\n  ```bash\n  npm run dev\n  ```\n\n## Project Structure\n\nThe project is divided into the following directories:\n\n- **`/server`**: The main project folder containing the source code and tests.\n  - **`/src`**: Contains all the application logic, following a **Model-Controller-Service-Routes** architecture.\n  - **`/tests`**: Contains all the unit and integration tests for the application.\n\n## Architecture\n\nThe project follows the **Model-Controller-Service-Routes** architecture:\n- **Model**: Represents the data and the logic for interacting with the database.\n- **Controller**: Manages the incoming HTTP requests and responses. The controllers are responsible for calling services to execute business logic.\n- **Service**: Contains the core business logic. The services are responsible for interacting with models and handling the application logic.\n- **Routes**: Defines the API endpoints and links each route to the corresponding controller.\n\n## Getting Started\n\n1. Clone this repository.\n2. Copy the example `.env` and fill it with your environment-specific values:\n    ```bash\n    cp server/example.env server/.env\n    ```\n3. Install dependencies:\n   ```bash\n   npm install\n   ```\n4. Set up the development database:\n   ```bash\n   ./server/database.dev.sh\n   ```\n5. Run the application:\n   ```bash\n   npm run dev\n   ```\n\n## Environment Configuration\n\nThe `.env` file contains the following environment variables:\n\nCertainly! Here’s the `.env` configuration represented as a table for better readability:\n\n---\n\n## Environment Configuration\n\n| **Variable**         | **Description**                                   | **Example Value**      |\n|----------------------|---------------------------------------------------|------------------------|\n| `HOST`               | The host for the application to listen on         | `0.0.0.0`              |\n| `PORT`               | The port for the application to listen on         | `5001`                 |\n| `POSTGRES_PORT`      | The port for the PostgreSQL database              | `5432`                 |\n| `POSTGRES_USER`      | The PostgreSQL username                           | `postgres`             |\n| `POSTGRES_PASSWORD`  | The PostgreSQL password                           | `postgres`             |\n| `POSTGRES_HOST`      | The host for the PostgreSQL database              | `0.0.0.0`              |\n| `POSTGRES_DB`        | The name of the PostgreSQL database               | `postgres`             |\n| `DATABASE_LOGGING`   | Enables or disables database logging              | `false`                |\n| `JWT_SECRET`         | The secret key for signing JWT tokens             | `anysecret`            |\n| `CORS_ORIGIN`        | The allowed origin for CORS                       | `*`                    |\n## Testing\n\nTo set up testing, launch the Dockerized test database by running:\n```bash\n./database.test.sh\n```\n\nThen, run the tests:\n- To run the tests without coverage:\n  ```bash\n  npm run test\n  ```\n\n- To run the tests with coverage tracking:\n  ```bash\n  npm run test:coverage\n  ```\n## Documentation\n\nA Swagger file is autogenerated and can be found on the endpoint /api/api-docs/swagger/ using controllers.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloriangolling%2Fbackend_typescript_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloriangolling%2Fbackend_typescript_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloriangolling%2Fbackend_typescript_template/lists"}