docs: added more description comments in code with links
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* eslint config
|
||||
* https://github.com/Sairyss/backend-best-practices#static-code-analysis
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
|
||||
@@ -331,7 +331,7 @@ Entities:
|
||||
- Domain entities data should be modelled to accommodate business logic, not some database schema.
|
||||
- Entities must protect their invariants, try to avoid public setters - update state using methods and execute invariant validation on each update if needed (this can be a simple `validate()` method that checks if business rules are not violated by update).
|
||||
- Must be consistent on creation. Validate Entities and other domain objects on creation and throw an error on first failure. [Fail Fast](https://en.wikipedia.org/wiki/Fail-fast).
|
||||
- Avoid no-arg (empty) constructors, accept and validate all required properties in a constructor (or in a factory method like `create()`).
|
||||
- Avoid no-arg (empty) constructors, accept and validate all required properties in a constructor (or in a [factory method](https://en.wikipedia.org/wiki/Factory_method_pattern) like `create()`).
|
||||
- For optional properties that require some complex setting up, [Fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) and [Builder Pattern](https://refactoring.guru/design-patterns/builder) can be used.
|
||||
- Make Entities partially immutable. Identify what properties shouldn't change after creation and make them `readonly` (for example `id` or `createdAt`).
|
||||
|
||||
|
||||
23069
package-lock.json
generated
23069
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,9 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
/**
|
||||
* Database migration for schema changes
|
||||
* https://github.com/Sairyss/backend-best-practices#managing-schema-changes
|
||||
*/
|
||||
export class CreateTables1631645442017 implements MigrationInterface {
|
||||
name = 'CreateTables1631645442017';
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ import { NonFunctionProperties } from '@libs/types';
|
||||
import { createdAtUpdatedAtMock } from '@src/libs/test-utils/mocks/generic-model-props.mock';
|
||||
import { UserOrmEntity } from '../user.orm-entity';
|
||||
|
||||
/**
|
||||
* Seeding database with dummy data
|
||||
* https://github.com/Sairyss/backend-best-practices#data-seeding
|
||||
*/
|
||||
export const userSeeds: NonFunctionProperties<UserOrmEntity>[] = [
|
||||
{
|
||||
...createdAtUpdatedAtMock,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Load testing with Artillery.
|
||||
# Can also be good for seeding database with lots of dummy data.
|
||||
# https://github.com/Sairyss/backend-best-practices#load-testing
|
||||
# https://www.npmjs.com/package/artillery
|
||||
# https://www.npmjs.com/package/artillery-plugin-faker
|
||||
config:
|
||||
|
||||
@@ -8,7 +8,10 @@ import { getTestServer, TestServer } from '../../jestSetupAfterEnv';
|
||||
|
||||
const feature = loadFeature('tests/user/create-user/create-user.feature');
|
||||
|
||||
// e2e test implementing a Gherkin feature file
|
||||
/**
|
||||
* e2e test implementing a Gherkin feature file
|
||||
* https://github.com/Sairyss/backend-best-practices#testing
|
||||
*/
|
||||
|
||||
defineFeature(feature, test => {
|
||||
let testServer: TestServer;
|
||||
|
||||
Reference in New Issue
Block a user