1.2.8 • Published 2 years ago

@secjs/base v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Base 📐

Base stuffs for any NodeJS project

GitHub followers GitHub stars

The intention behind this repository is to always maintain a Base project to any NodeJS project.

Installation

To use the high potential from this package you need to install first this other packages from SecJS, it keeps as dev dependency because one day @secjs/core will install everything once.

npm install @secjs/contracts @secjs/exceptions @secjs/utils

Then you can install the package using:

npm install @secjs/base

BaseService

Use to get nice methods to use with @secjs/base repositories

import { User } from 'app/Models/User'
import { NotFoundException } from '@nestjs/common'
import { BaseService } from '@secjs/base/services/BaseService'
import { ContactResource } from 'app/Resources/ContactResource'
import { ContactRepository } from 'app/Repositories/ContactRepository'

class ContactService extends BaseService<User> {
  protected resourceName = 'contact'
  protected resource = new ContactResource()
  protected repository = new ContactRepository()
  protected NotFoundException: any = NotFoundException // Define exception or use NotFoundException default from @secjs/exceptions

  // You can subscribe BaseService methods in here if you want!
}

LucidRepository

Use LucidRepository to get nice methods based on ApiRequestContract

import { User } from 'app/Models/User'
import { LucidRepository } from '@secjs/base/repositories/LucidRepository'

class UserRepository extends LucidRepository<User> {
  model = User // Give the Model value to Lucid, so he knows what to work with.

  wheres = ['id', 'name'] // What wheres can be executed by client
  relations = ['contacts'] // What relations can be get by client

  // Both, wheres and relations will only work for external requests.
  
  // You can subscribe LucidRepository methods in here if you want!  
}

TypeOrmRepository

Use TypeOrmRepository to get nice methods based on ApiRequestContract

import { User } from 'app/Models/User'
import { TypeOrmRepository } from '@secjs/base/repositories/TypeOrmRepository'

class UserRepository extends TypeOrmRepository<User> {
  model = User // Give the Model value to Lucid, so he knows what to work with.
  
  wheres = ['id', 'name'] // What wheres can be executed by client
  relations = ['contacts'] // What relations can be get by client
  
  // Both, wheres and relations will only work for external requests.
  
  // You can subscribe TypeOrmRepository methods in here if you want!
}

MongooseRepository

Use MongooseRepository to get nice methods based on ApiRequestContract

import { User, UserDocument } from 'app/Schemas/User'
import { MongooseRepository } from '@secjs/base/repositories/MongooseRepository'

class UserRepository extends MongooseRepository<UserDocument> {
  model = User // Give the Model value to Mongoose, so he knows what to work with.

  wheres = ['id', 'name'] // What wheres can be executed by client
  relations = ['contacts'] // What relations can be get by client
  
  // Both, wheres and relations will only work for external requests.

  // You can subscribe MongooseRepository methods in here if you want!  
}

PrismaRepository

Use PrismaRepository to get nice methods based on ApiRequestContract

import { User } from 'app/Models/User'
import { PrismaRepository } from '@secjs/base/repositories/PrismaRepository'

class UserRepository extends PrismaRepository<User> {
  model = User // Give the Model value to Lucid, so he knows what to work with.

  wheres = ['id', 'name'] // What wheres can be executed by client
  relations = ['contacts'] // What relations can be get by client
  
  // Both, wheres and relations will only work for external requests.

  // You can subscribe PrismaRepository methods in here if you want!
}

License

Made with 🖤 by jlenon7 :wave:

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago