https://github.com/secjs/base
📐 Base classes with prebuild methods for Node.js
https://github.com/secjs/base
base nodejs prebuild
Last synced: about 1 month ago
JSON representation
📐 Base classes with prebuild methods for Node.js
- Host: GitHub
- URL: https://github.com/secjs/base
- Owner: SecJS
- License: mit
- Created: 2021-06-13T15:50:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-17T20:25:52.000Z (over 3 years ago)
- Last Synced: 2025-04-19T21:25:51.743Z (about 1 month ago)
- Topics: base, nodejs, prebuild
- Language: TypeScript
- Homepage:
- Size: 1.17 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Base 📐
> Base stuffs for any NodeJS project
[](https://github.com/jlenon7?tab=followers)
[](https://github.com/secjs/base/stargazers/)
![]()
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.```bash
npm install @secjs/contracts @secjs/exceptions @secjs/utils
```> Then you can install the package using:
```bash
npm install @secjs/base
```### BaseService
> Use to get nice methods to use with @secjs/base repositories
```ts
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 {
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
```ts
import { User } from 'app/Models/User'
import { LucidRepository } from '@secjs/base/repositories/LucidRepository'class UserRepository extends LucidRepository {
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
```ts
import { User } from 'app/Models/User'
import { TypeOrmRepository } from '@secjs/base/repositories/TypeOrmRepository'class UserRepository extends TypeOrmRepository {
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
```ts
import { User, UserDocument } from 'app/Schemas/User'
import { MongooseRepository } from '@secjs/base/repositories/MongooseRepository'class UserRepository extends MongooseRepository {
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
```ts
import { User } from 'app/Models/User'
import { PrismaRepository } from '@secjs/base/repositories/PrismaRepository'class UserRepository extends PrismaRepository {
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](https://github.com/jlenon7) :wave: