backend/README.md

94 lines
5.4 KiB
Markdown
Raw Permalink Normal View History

# @lfk/backend
2020-11-24 16:51:18 +00:00
Backend Server
2021-01-21 14:43:11 +00:00
## Quickstart 🐳
> Use this to run the backend with a postgresql db in docker
2021-01-21 14:43:11 +00:00
1. Clone the repo or copy the docker-compose
2. Run in toe folder that contains the docker-compose file: `docker-compose up -d`
3. Visit http://127.0.0.1:4010/api/docs to check if the server is running
4. You can now use the default admin user (`demo:demo`)
2021-01-21 14:43:11 +00:00
## Dev Setup 🛠
> Local dev setup utilizing sqlite3 as the database.
1. Rename the .env.example file to .env (you can adjust app port and other settings, if needed)
2. Install Dependencies
```bash
pnpm i
```
3. Start the server
```bash
pnpm dev
```
2021-01-21 14:43:11 +00:00
### Run Tests
```bash
# Run tests once (server has to run)
pnpm test
2021-01-21 14:43:11 +00:00
# Run test in watch mode (reruns on change)
pnpm test:watch
2020-11-27 20:40:42 +00:00
2021-01-21 14:43:11 +00:00
# Run test in ci mode (automaticly starts the dev server)
pnpm test:ci
2021-01-21 14:43:11 +00:00
```
### Use your own mail templates
> You use your own mail templates by replacing the default ones we provided (either in-code or by mounting them into the /app/static/mail_templates folder).
The mail templates always come in a .html and a .txt variant to provide compatability with legacy mail clients.
Currently the following templates exist:
* pw-reset.(html/txt)
2021-01-21 14:43:11 +00:00
### Generate Docs
2020-11-24 18:54:14 +00:00
```bash
pnpm docs
2020-11-24 18:54:14 +00:00
```
## ENV Vars
> You can provide them via .env file or docker env vars.
2021-03-04 15:28:13 +00:00
> You can use the `test:ci:generate_env` package script to generate a example env (uses bs data as test server and ignores the errors).
2023-02-02 11:56:23 +00:00
| Name | Type | Default | Description |
| ---------------------- | ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------- |
| APP_PORT | Number | 4010 | The port the backend server listens on. Is optional. |
| DB_TYPE | String | N/A | The type of the db u want to use. It has to be supported by typeorm. Possible: `sqlite`, `mysql`, `postgresql` |
| DB_HOST | String | N/A | The db's host's ip-address/fqdn or file path for sqlite |
| DB_PORT | String | N/A | The db's port |
| DB_USER | String | N/A | The user for accessing the db |
| DB_PASSWORD | String | N/A | The user's password for accessing the db |
| DB_NAME | String | N/A | The db's name |
| NODE_ENV | String | dev | The apps env - influences debug info. Also when the env is set to "test", mailing errors get ignored. |
| POSTALCODE_COUNTRYCODE | String/CountryCode | N/A | The countrycode used to validate address's postal codes |
| PHONE_COUNTRYCODE | String/CountryCode | null (international) | The countrycode used to validate phone numers |
| SEED_TEST_DATA | Boolean | False | If you want the app to seed some example data set this to true |
| MAILER_URL | String(Url) | N/A | The mailer's base url (no trailing slash) |
| MAILER_KEY | String | N/A | The mailer's api key. |
| IMPRINT_URL | String(Url) | /imprint | The link to a imprint page for the system (Defaults to the frontend's imprint) |
| PRIVACY_URL | String(Url) | /privacy | The link to a privacy page for the system (Defaults to the frontend's privacy page) |
2021-01-26 19:41:44 +00:00
## Recommended Editor
[Visual Studio Code](https://code.visualstudio.com/)
### Recommended Extensions
* will be automatically recommended via ./vscode/extensions.json
2021-01-21 14:43:11 +00:00
## Staging
### Branches & Tags
* vX.Y.Z: Release tags created from the main branch
* The version numbers follow the semver standard
* A new release tag automaticly triggers the release ci pipeline
* main: Protected "release" branch
* The latest tag of the docker image get's build from this
* dev: Current dev branch for merging the different feature branches and bugfixes
2023-02-02 11:56:23 +00:00
* New releases get created as tags from this
2021-01-21 14:43:11 +00:00
* The dev tag of the docker image get's build from this
* Only push minor changes to this branch!
* To merge a feature branch into this please create a pull request
* feature/xyz: Feature branches - naming scheme: `feature/issueid-title`
* bugfix/xyz: Branches for bugfixes - naming scheme:`bugfix/issueid-title`