Giter Site home page Giter Site logo

borjapazr / express-typescript-skeleton Goto Github PK

View Code? Open in Web Editor NEW
456.0 9.0 56.0 6.91 MB

๐Ÿ”ฐ๐Ÿฆธ Template to start developing a REST API with Node.js (Express), TypeScript, Ts.ED, ESLint, Prettier, Husky, Prisma, etc.

Home Page: https://express-typescript-skeleton.bpaz.dev/api/docs

License: MIT License

JavaScript 7.53% Shell 0.49% Dockerfile 1.09% Makefile 2.16% TypeScript 88.72%
express nodejs typescript eslint prettier docker docker-compose dockerfile jest supertest jwt ddd hexagonal-architecture best-practices makefile tsconfig-paths pm2 prisma tsed hacktoberfest

express-typescript-skeleton's People

Contributors

borjapazr avatar dependabot[bot] avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

express-typescript-skeleton's Issues

๐Ÿ’ก Discussion: Vertical Slice Architecture

Feature Request Checklist

Overview

This is more of a discussion than a feature request.

What do you think about organizing the features using the architecture that is commonly known as "Vertical Slice architecture"?

The current structure is:

  • application
    • feature1
    • ...
  • domain
    • feature1
    • ...
  • infrastructure
    • feature1
    • ...
  • presentation
    • ...

The proposed structure would organize every logic of a feature in a feature folder:

  • features
    • feature1
      • application
      • domain
      • infrastructure
      • presentation
      • ...
  • domain (common shared domain logic)
  • application (common shared application logic)
  • infrastructure (...)
  • presentation (generic logic where each feature will register it's presentation components)

I think this will improve cohesion and reduce coupling by setting clear features boundaries. Each boundary can specify exactly what should be shared with other parts of the system. Having each logic of a feature in a feature root folder will also help when traversing the code and learning about what the feature has implemented.

References

Additional Info

No response

Prisma relations error

Hi,

First of all thank you for this complete project.

I'm currently having a problem using one-to-one relationships with Prisma.

It's probably due to a misunderstanding of the code on my part but I've been blocking for a while now.

I'm trying to create a relationship between an entity called Project with another called ProjectDrive.

This is the .prisma file entities declaration :

model Project {
  id                Int             @id @default(autoincrement())
  uuid              String          @unique @db.VarChar(1000)
  publicName        String          @db.VarChar(255)
  privateName       String          @db.VarChar(255)
  slug              String          @db.VarChar(255)
  description       String          @db.VarChar(500)
  projectDrive      ProjectDrive?
  createdAt         DateTime?       @default(now()) @db.Timestamptz(3)
  createdBy         String?         @db.VarChar(255)
  updatedAt         DateTime?       @default(now()) @updatedAt @db.Timestamptz(3)
  updatedBy         String?         @db.VarChar(255)
  deletedAt         DateTime?       @db.Timestamptz(3)
  deletedBy         String?         @db.VarChar(255)
}

model ProjectDrive {
  id                        Int                   @id                                   @default(autoincrement())
  uuid                      String                @unique                               @db.VarChar(1000)
  folderId                  String?               @unique                               @db.VarChar(500)
  name                      String?               @unique                               @db.VarChar(500)
  url                       String?               @db.VarChar(500)
  project                   Project?              @relation(fields: [puid], references: [uuid])
  puid                      String?               @unique
  createdAt                 DateTime?             @default(now())                       @db.Timestamptz(3)
  createdBy                 String?               @db.VarChar(255)
  updatedAt                 DateTime?             @default(now())                       @updatedAt                    @db.Timestamptz(3)
  updatedBy                 String?               @db.VarChar(255)
  deletedAt                 DateTime?             @db.Timestamptz(3)
  deletedBy                 String?               @db.VarChar(255)
}

After migrate and generate I got this error :

Type 'ProjectDriveModel' is not assignable to type '(Without<ProjectDriveCreateInput, ProjectDriveUncheckedCreateInput> & ProjectDriveUncheckedCreateInput) | (Without<...> & ProjectDriveCreateInput)'.
  Type 'ProjectDriveModel' is not assignable to type 'Without<ProjectDriveUncheckedCreateInput, ProjectDriveCreateInput> & ProjectDriveCreateInput'.
    Type 'ProjectDriveModel' is not assignable to type 'Without<ProjectDriveUncheckedCreateInput, ProjectDriveCreateInput>'.
      Types of property 'id' are incompatible.
        Type 'number' is not assignable to type 'undefined'.

I understand why it failed in the code :

ProjectDriveModel generated by prisma :

export declare class ProjectDriveModel implements ProjectDrive {
    id: number;
    uuid: string;
    folderId: string | null;
    name: string | null;
    url: string | null;
    project: ProjectModel | null;
    puid: string | null;
    createdAt: Date | null;
    createdBy: string | null;
    updatedAt: Date | null;
    updatedBy: string | null;
    deletedAt: Date | null;
    deletedBy: string | null;
}

ProjectDriveCreateInput :

export type ProjectDriveCreateInput = {
    uuid: string
    folderId?: string | null
    name?: string | null
    url?: string | null
    project?: ProjectCreateNestedOneWithoutProjectDriveInput
    createdAt?: Date | string | null
    createdBy?: string | null
    updatedAt?: Date | string | null
    updatedBy?: string | null
    deletedAt?: Date | string | null
    deletedBy?: string | null
}

ProjectDriveUncheckedCreateInput :

export type ProjectDriveUncheckedCreateInput = {
    id?: number
    uuid: string
    folderId?: string | null
    name?: string | null
    url?: string | null
    puid?: string | null
    createdAt?: Date | string | null
    createdBy?: string | null
    updatedAt?: Date | string | null
    updatedBy?: string | null
    deletedAt?: Date | string | null
    deletedBy?: string | null
  }

It seems that ProjectDriveModel is in conflict with ProjectDriveUncheckedCreateInput on the id field, but I checked if I remove the relation those files are the same, and I got no errors.

I'm really out of ideas, if you can help me ๐Ÿ™๐Ÿผ

Tell me if it's not clear or if you need more explanations !

Thank you !

INJECTION_ERROR: Injection failed on ValidationPipe > Ajv

Environment:

computer: macbook pro
os: MacOS Monterey
node version: v18.12.1
npm version: v8.19.2
yarn version: 1.22.18

To reproduce:

git checkout v2.2.2
git switch -c dev
yarn
yarn prisma:generate
yarn run dev

Then I get the output:

[2023-01-07 03:07:11.711] ERROR uncaughtException: Injection failed on ValidationPipe > Ajv
Origin: Cannot read properties of undefined (reading 'code')
INJECTION_ERROR: Injection failed on ValidationPipe > Ajv
Origin: Cannot read properties of undefined (reading 'code')
at Function.throwInjectorError (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/errors/InjectionError.ts:44:11)
at InjectorService.resolve (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:640:22)
at InjectorService.invoke (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:211:21)
at InjectorService.loadSync (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:264:14)
at InjectorService.load (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:336:10)
at async PlatformBuilder.loadInjector (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/common/src/builder/PlatformBuilder.ts:202:5)
at async PlatformBuilder.runLifecycle (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/common/src/builder/PlatformBuilder.ts:189:5)
at async start (/Users/zhangjie/Work/express-typescript-skeleton/src/index.ts:13:20) INJECTION_ERROR: Injection failed on ValidationPipe > Ajv
Origin: Cannot read properties of undefined (reading 'code')
at Function.throwInjectorError (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/errors/InjectionError.ts:44:11)
at InjectorService.resolve (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:640:22)
at InjectorService.invoke (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:211:21)
at InjectorService.loadSync (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:264:14)
at InjectorService.load (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/di/src/services/InjectorService.ts:336:10)
at async PlatformBuilder.loadInjector (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/common/src/builder/PlatformBuilder.ts:202:5)
at async PlatformBuilder.runLifecycle (/Users/zhangjie/Work/express-typescript-skeleton/node_modules/@tsed/common/src/builder/PlatformBuilder.ts:189:5)
at async start (/Users/zhangjie/Work/express-typescript-skeleton/src/index.ts:13:20)
[nodemon] clean exit - waiting for changes before restart

Improve logger

The current logger can be modified to improve the developer's experience in detecting potential problems or bugs.

  • Remove color characters from log files when there is a compilation error. This is caused by ts-node and the --pretty property (TS_NODE_PRETTY)
  • Evaluate the use of other logging libraries (pino, @tsed/logger, log4js, etc.)
  • Add a correlation id to all logs of the same request

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @cspell/dict-software-terms to v3.3.20
  • chore(deps): update dependency @cspell/dict-typescript to v3.1.4
  • chore(deps): update dependency jest-mock-extended to v3.0.7
  • chore(deps): update dependency eslint-plugin-jest-extended to v2.4.0
  • chore(deps): update dependency eslint-plugin-jsonc to v2.15.1
  • chore(deps): update dependency eslint-plugin-simple-import-sort to v12.1.0
  • chore(deps): update dependency eslint-plugin-sonarjs to ^0.25.0
  • chore(deps): update dependency eslint-plugin-unused-imports to v3.2.0
  • chore(deps): update dependency eslint-plugin-yml to v1.14.0
  • chore(deps): update dependency markdownlint to ^0.34.0
  • chore(deps): update dependency markdownlint-cli to ^0.40.0
  • chore(deps): update dependency tsx to v4.9.3
  • chore(deps): update dependency typescript to v5.4.5
  • chore(deps): update docker/dockerfile docker tag to v1.7
  • chore(deps): update node.js to v20.12.2
  • fix(deps): update dependency @tsed/ajv to v7.68.5
  • fix(deps): update dependency @tsed/common to v7.68.5
  • fix(deps): update dependency @tsed/components-scan to v7.68.5
  • fix(deps): update dependency @tsed/core to v7.68.5
  • fix(deps): update dependency @tsed/di to v7.68.5
  • fix(deps): update dependency @tsed/exceptions to v7.68.5
  • fix(deps): update dependency @tsed/ioredis to v7.68.5
  • fix(deps): update dependency @tsed/json-mapper to v7.68.5
  • fix(deps): update dependency @tsed/logger to v6.7.5
  • fix(deps): update dependency @tsed/openspec to v7.68.5
  • fix(deps): update dependency @tsed/platform-express to v7.68.5
  • fix(deps): update dependency @tsed/prisma to v7.68.5
  • fix(deps): update dependency @tsed/schema to v7.68.5
  • fix(deps): update dependency @tsed/swagger to v7.68.5
  • fix(deps): update dependency ajv to v8.13.0
  • fix(deps): update dependency ioredis to v5.4.1
  • fix(deps): update dependency pino to v8.21.0
  • fix(deps): update prisma monorepo to v5.13.0 (@prisma/client, prisma)
  • chore(deps): update dependency @cspell/dict-es-es to v3
  • chore(deps): update dependency @cspell/dict-node to v5
  • chore(deps): update dependency @types/node-emoji to v2
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-plugin-jest to v28
  • chore(deps): update dependency eslint-plugin-markdown to v5
  • chore(deps): update dependency eslint-plugin-n to v17
  • chore(deps): update dependency eslint-plugin-security to v3
  • chore(deps): update dependency eslint-plugin-sonarjs to v1
  • chore(deps): update dependency eslint-plugin-unicorn to v52
  • chore(deps): update dependency supertest to v7
  • chore(deps): update softprops/action-gh-release action to v2
  • fix(deps): update dependency pino to v9
  • fix(deps): update dependency pino-http to v10
  • fix(deps): update dependency pino-pretty to v11
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

asdf
.tool-versions
  • node 20.11.1
docker-compose
docker/docker-compose.yml
  • postgres 16
  • redis 7
dockerfile
docker/Dockerfile
  • docker/dockerfile 1.6-labs
  • node 20.11.1-alpine
github-actions
.github/actions/setup-environment/action.yml
  • asdf-vm/actions v3
  • actions/cache v4
  • asdf-vm/actions v3
  • actions/cache v4
.github/workflows/cd.yml
  • actions/checkout v4
  • softprops/action-gh-release v1
  • actions/checkout v4
  • docker/login-action v3
  • docker/metadata-action v5
  • docker/build-push-action v5
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/checkout v4
  • actions/checkout v4
npm
package.json
  • @ngneat/falso ^7.2.0
  • @prisma/client ^5.10.2
  • @tsed/ajv ^7.62.2
  • @tsed/common ^7.62.2
  • @tsed/components-scan ^7.62.2
  • @tsed/core ^7.62.2
  • @tsed/di ^7.62.2
  • @tsed/exceptions ^7.62.2
  • @tsed/ioredis ^7.62.2
  • @tsed/json-mapper ^7.62.2
  • @tsed/logger ^6.6.3
  • @tsed/openspec ^7.62.2
  • @tsed/platform-express ^7.62.2
  • @tsed/prisma ^7.62.2
  • @tsed/schema ^7.62.2
  • @tsed/swagger ^7.62.2
  • ajv ^8.12.0
  • argon2 ^0.40.1
  • body-parser ^1.20.2
  • compression ^1.7.4
  • cookie-parser ^1.4.6
  • cors ^2.8.5
  • dotenv-defaults ^5.0.2
  • dotenv-expand ^11.0.6
  • endent ^2.1.0
  • express 4
  • fast-equals ^5.0.1
  • figlet ^1.7.0
  • file-stream-rotator ^1.0.0
  • http-status-codes ^2.3.0
  • ioredis ^5.3.2
  • jsonwebtoken ^9.0.2
  • just-is-empty ^3.4.1
  • luxon ^3.4.4
  • method-override ^3.0.0
  • multer 1.4.5-lts.1
  • node-emoji ^2.1.3
  • pino ^8.19.0
  • pino-http ^9.0.0
  • pino-pretty ^10.3.1
  • reflect-metadata ^0.2.1
  • source-map-support ^0.5.21
  • ts-node ^10.9.2
  • uuid ^9.0.1
  • @commitlint/cli ^19.0.3
  • @commitlint/config-conventional ^19.0.3
  • @cspell/dict-bash ^4.1.3
  • @cspell/dict-companies ^3.0.31
  • @cspell/dict-es-es ^2.4.0
  • @cspell/dict-filetypes ^3.0.3
  • @cspell/dict-html ^4.0.5
  • @cspell/dict-lorem-ipsum ^4.0.0
  • @cspell/dict-node ^4.0.3
  • @cspell/dict-npm ^5.0.15
  • @cspell/dict-software-terms ^3.3.18
  • @cspell/dict-typescript ^3.1.2
  • @tsed/cli-plugin-prisma ^5.1.0
  • @types/body-parser ^1.19.5
  • @types/compression ^1.7.5
  • @types/cookie-parser ^1.4.7
  • @types/cors ^2.8.17
  • @types/dotenv-defaults ^2.0.4
  • @types/express ^4.17.21
  • @types/figlet ^1.5.8
  • @types/jest ^29.5.12
  • @types/jsonwebtoken ^9.0.6
  • @types/luxon ^3.4.2
  • @types/method-override ^0.0.35
  • @types/multer ^1.4.11
  • @types/node ^20.11.24
  • @types/node-emoji ^1.8.2
  • @types/source-map-support ^0.5.10
  • @types/supertest ^6.0.2
  • @types/swagger-schema-official ^2.0.25
  • @types/uuid ^9.0.8
  • @typescript-eslint/eslint-plugin ^7.1.0
  • @typescript-eslint/parser ^7.1.0
  • commitizen ^4.3.0
  • copyfiles ^2.4.1
  • cross-env ^7.0.3
  • cspell ^8.5.0
  • cz-conventional-changelog ^3.3.0
  • eslint ^8.57.0
  • eslint-config-airbnb-base ^15.0.0
  • eslint-config-airbnb-typescript ^18.0.0
  • eslint-config-prettier ^9.1.0
  • eslint-import-resolver-typescript ^3.6.1
  • eslint-plugin-deprecation ^2.0.0
  • eslint-plugin-eslint-comments ^3.2.0
  • eslint-plugin-hexagonal-architecture ^1.0.3
  • eslint-plugin-import ^2.29.1
  • eslint-plugin-jest ^27.9.0
  • eslint-plugin-jest-extended ^2.0.0
  • eslint-plugin-jsonc ^2.13.0
  • eslint-plugin-markdown ^3.0.1
  • eslint-plugin-n ^16.6.2
  • eslint-plugin-optimize-regex ^1.2.1
  • eslint-plugin-prefer-arrow ^1.2.3
  • eslint-plugin-prettier ^5.1.3
  • eslint-plugin-promise ^6.1.1
  • eslint-plugin-security ^2.1.1
  • eslint-plugin-simple-import-sort ^12.0.0
  • eslint-plugin-sonarjs ^0.24.0
  • eslint-plugin-unicorn ^51.0.1
  • eslint-plugin-unused-imports ^3.1.0
  • eslint-plugin-yml ^1.12.2
  • get-tsconfig ^4.7.2
  • http-server ^14.1.1
  • husky ^9.0.11
  • ioredis-mock ^8.9.0
  • is-ci ^3.0.1
  • jest ^29.7.0
  • jest-extended ^4.0.2
  • jest-mock-extended ^3.0.5
  • lint-staged ^15.2.2
  • markdownlint ^0.33.0
  • markdownlint-cli ^0.39.0
  • nodemon ^3.1.0
  • npm-check-updates ^16.14.15
  • npm-package-json-lint ^7.1.0
  • npm-package-json-lint-config-default ^6.0.0
  • npm-run-all2 ^6.1.2
  • prettier ^3.2.5
  • prettier-plugin-packagejson ^2.4.12
  • prettier-plugin-prisma ^5.0.0
  • prisma ^5.10.2
  • rimraf ^5.0.5
  • standard-version ^9.5.0
  • supertest ^6.3.4
  • ts-jest ^29.1.2
  • tsc-alias ^1.8.8
  • tsconfig-paths ^4.2.0
  • tsx ^4.7.1
  • typescript ^5.3.3
  • yaml-eslint-parser ^1.2.2
  • node >=20.9.0
  • npm >=6.7.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.