2
1
mirror of https://github.com/Thream/api.git synced 2024-07-06 21:00:11 +02:00
api/README.md

125 lines
3.8 KiB
Markdown
Raw Permalink Normal View History

2023-07-22 16:26:27 +02:00
<h1 align="center"><a href="https://api.thream.theoludwig.fr/documentation">Thream/api</a></h1>
2021-10-24 04:06:16 +02:00
2023-12-28 05:06:48 +01:00
<p align="center">
<strong>⚠️ This project is not maintained anymore, you can still use the code as you wish and fork it to maintain it yourself.</strong>
</p>
2021-10-24 04:06:16 +02:00
<p align="center">
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
<a href="./CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
<br />
<a href="https://github.com/Thream/api/actions/workflows/analyze.yml"><img src="https://github.com/Thream/api/actions/workflows/analyze.yml/badge.svg?branch=develop" /></a>
<a href="https://github.com/Thream/api/actions/workflows/build.yml"><img src="https://github.com/Thream/api/actions/workflows/build.yml/badge.svg?branch=develop" /></a>
<a href="https://github.com/Thream/api/actions/workflows/lint.yml"><img src="https://github.com/Thream/api/actions/workflows/lint.yml/badge.svg?branch=develop" /></a>
<a href="https://github.com/Thream/api/actions/workflows/test.yml"><img src="https://github.com/Thream/api/actions/workflows/test.yml/badge.svg?branch=develop" /></a>
<br />
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
2021-10-24 04:18:18 +02:00
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
2021-10-24 04:06:16 +02:00
</p>
## 📜 About
Thream's Application Programming Interface (API) to stay close with your friends and communities.
2021-10-24 04:06:16 +02:00
2023-12-28 05:06:48 +01:00
It uses [Thream/file-uploads-api](https://github.com/Thream/file-uploads-api) [v1.1.8](https://github.com/Thream/file-uploads-api/releases/tag/v1.1.8).
2022-04-08 21:36:29 +02:00
2021-10-24 04:06:16 +02:00
## ⚙️ Getting Started
### Prerequisites
2021-10-24 04:18:18 +02:00
- [Node.js](https://nodejs.org/) >= 16.0.0
- [npm](https://www.npmjs.com/) >= 8.0.0
- [PostgreSQL](https://www.postgresql.org/)
2021-10-24 04:06:16 +02:00
### Installation
```sh
# Clone the repository
2023-07-02 18:54:02 +02:00
git clone git@github.com:Thream/api.git
2021-10-24 04:06:16 +02:00
# Go to the project root
cd api
2023-07-22 16:26:27 +02:00
# Install dependencies
npm clean-install
2021-10-24 04:06:16 +02:00
# Configure environment variables
cp .env.example .env
2023-07-22 16:26:27 +02:00
# Generate Prisma client types
2023-05-13 20:09:02 +02:00
npm run prisma:generate
2021-10-24 04:06:16 +02:00
```
2023-07-22 16:26:27 +02:00
### Database Setup
2021-10-24 04:06:16 +02:00
```sh
2021-10-24 04:18:18 +02:00
# Create a new user and database
psql
2023-07-22 16:26:27 +02:00
CREATE DATABASE thream;
CREATE USER thream_user with encrypted password 'password';
2021-10-24 04:18:18 +02:00
ALTER USER thream_user WITH SUPERUSER;
```
2023-07-22 16:26:27 +02:00
### Database Production migration
```sh
npm run prisma:migrate:deploy
```
### Local Development environment
Recommended to use [VSCode: Remote development in Containers](https://code.visualstudio.com/docs/remote/containers-tutorial).
#### Database Development migration
2021-10-24 04:18:18 +02:00
```sh
# Run Prisma migrations
npm run prisma:migrate:dev
2023-07-22 16:26:27 +02:00
# Reset the database (WARNING: This will delete all data)
npm run prisma:migrate:reset
2021-10-24 04:18:18 +02:00
```
#### Usage
```sh
npm run dev
2023-07-22 16:26:27 +02:00
```
##### Services started
- `api`: <http://127.0.0.1:8080>
- [Maildev](https://maildev.github.io/maildev/): <http://127.0.0.1:1080>
- [Prisma Studio](https://www.prisma.io/studio): <http://127.0.0.1:5555>
2021-10-24 04:18:18 +02:00
2023-07-22 16:26:27 +02:00
##### Commands
```sh
# Build, Lint and Test
npm run build
npm run build:typescript
npm run lint:editorconfig
npm run lint:markdown
npm run lint:eslint
npm run lint:prettier
npm run test
```
### Production environment (with [Docker](https://www.docker.com/))
```sh
docker compose up --build
2021-10-24 04:06:16 +02:00
```
## 💡 Contributing
2021-10-24 04:18:18 +02:00
Anyone can help to improve the project, submit a Feature Request, a bug report or
even correct a simple spelling mistake.
2021-10-24 04:06:16 +02:00
2021-10-24 04:18:18 +02:00
The steps to contribute can be found in [CONTRIBUTING.md](./CONTRIBUTING.md).
2021-10-24 04:06:16 +02:00
## 📄 License
[MIT](./LICENSE)