This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
api/CONTRIBUTING.md

101 lines
3.1 KiB
Markdown
Raw Permalink Normal View History

2021-10-24 04:06:16 +02:00
# 💡 Contributing
Thanks a lot for your interest in contributing to **Thream/api**! 🎉
## Code of Conduct
2021-10-24 04:18:18 +02:00
**Thream** has adopted the [Contributor Covenant](https://www.contributor-covenant.org/) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](./CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
2021-10-24 04:06:16 +02:00
## Open Development
All work on **Thream/api** happens directly on [GitHub](https://github.com/Thream). Both core team members and external contributors send pull requests which go through the same review process.
## Types of contributions
- Reporting a bug.
- Suggest a new feature idea.
2021-10-24 04:18:18 +02:00
- Correct spelling errors, improvements or additions to documentation files.
2021-10-24 04:06:16 +02:00
- Improve structure/format/performance/refactor/tests of the code.
## Pull Requests
2021-10-24 04:18:18 +02:00
- **Please first discuss** the change you wish to make via issues.
2021-10-24 04:06:16 +02:00
- Ensure your code respect linting.
2021-10-24 04:06:16 +02:00
- Make sure your **code passes the tests**.
If you're adding new features to **Thream/api**, please include tests.
## Commits
2023-05-13 20:09:02 +02:00
The commit message guidelines adheres to [Conventional Commits](https://www.conventionalcommits.org/) and [Semantic Versioning](https://semver.org/) for releases.
2021-10-24 04:06:16 +02:00
### Examples
```sh
2022-10-04 14:58:12 +02:00
git commit -m "feat: add POST /users/signup"
2021-10-24 04:06:16 +02:00
git commit -m "docs(readme): update installation process"
2022-10-04 14:58:12 +02:00
git commit -m "fix: should emit events to connected users"
2021-10-24 04:06:16 +02:00
```
## Directory Structure
```text
├── email
2021-10-24 04:18:18 +02:00
├── prisma
2021-10-24 04:06:16 +02:00
└── src
├── models
├── scripts
2021-10-24 04:06:16 +02:00
├── services
├── tools
└── typings
```
### Each folder explained
- `email` : email template(s) and translation(s)
2021-10-24 04:18:18 +02:00
- `prisma` : contains the prisma schema and migrations
2021-10-24 04:06:16 +02:00
- `src` : all source files
2021-10-24 04:18:18 +02:00
- `models` : models that represent tables in database as JSON schema
- `scripts` : scripts
2021-10-24 04:06:16 +02:00
- `services` : all REST API endpoints
- `tools` : configs and utilities
- `typings` : types gloablly used in the project
### Services folder explained with an example
We have API REST services for the `channels`.
2023-07-22 16:26:27 +02:00
Here is what potentially look like a folder structure for this service:
2021-10-24 04:06:16 +02:00
```text
└── src
└── services
└── channels
├── __test__
│ └── get.test.ts
├── [channelId]
│ ├── __test__
│ │ ├── delete.test.ts
│ │ └── put.test.ts
│ ├── delete.ts
│ ├── index.ts
│ └── put.ts
├── get.ts
└── index.ts
```
2023-07-22 16:26:27 +02:00
This folder structure will map to these REST API routes:
2021-10-24 04:06:16 +02:00
- GET `/channels`
- DELETE `/channels/:channelId`
- PUT `/channels/:channelId`
2021-10-24 04:18:18 +02:00
The folders after `src/services` : is the real path of the routes in the API except
folders starting and ending with `__` like `__test__` or `__utils__`.
2021-10-24 04:06:16 +02:00
The filenames correspond to the HTTP methods used (`get`, `post`, `put`, `delete`).
2022-10-04 14:58:12 +02:00
You can generate the boilerplate code for a new service with the `npm run generate` command.