🌜
🌞
@andresmeidla/crud-sequelize

@andresmeidla/crud-sequelize

v4.6.27-alpha.0

NestJs CRUD for RESTful APIs - Sequelize

npm install @andresmeidla/crud-sequelize

README

CRUD (@nestjsx/crud-sequelize)

for RESTful APIs built with NestJs


We believe that everyone who's working with NestJs and building some RESTful services and especially some CRUD functionality will find @nestjsx/crud microframework very useful.

Features

CRUD usage
  • Super easy to install and start using the full-featured controllers and services :point_right:

  • DB and service agnostic extendable CRUD controllers

  • Reach query parsing with filtering, pagination, sorting, relations, nested relations, cache, etc.

  • Framework agnostic package with query builder for a frontend usage

  • Query, path params and DTOs validation included

  • Overriding controller methods with ease

  • Tiny config (including globally)

  • Additional helper decorators

  • Swagger documentation

Install

npm i @nestjsx/crud-typeorm @nestjs/typeorm typeorm

To use it with sequelize:

npm i @nestjsx/crud-sequelize @nestjs/sequelize sequelize sequelize-typescript @types/sequelize
Note on using sequelize:

class-transcforment doesn't work well with sequelize classes so in order to user validations you have to supply a ClassDTO to the Crud decorator, or you can set validations: false and use sequelize-typescript validators or even your own.

Example:
In the following example we are use the UserDTO to the crud controller:
users.controller.ts

import { Controller } from '@nestjs/common';
import {
  Crud,
  CrudController,
} from '@nestjsx/crud';

import { UserDto } from './user.dto';
import User from './user.model';
import { UsersService } from './users.service';

@Crud({
  model: {
    type: UserDto,
  }
})
@Controller('/companies/:companyId/users')
export class UsersController implements CrudController<User> {
  constructor(public service: UsersService) {}
}

user.dto.ts

import { CrudValidationGroups } from '@nestjsx/crud';
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString, MaxLength, ValidateNested } from 'class-validator';
import { UserProfile } from '../../crud-typeorm/users-profiles';
const { CREATE, UPDATE } = CrudValidationGroups;

export class UserDto {
  @IsOptional({ groups: [UPDATE] })
  @IsNotEmpty({ groups: [CREATE] })
  @IsString({ always: true })
  @MaxLength(255, { always: true })
  @IsEmail({ require_tld: false }, { always: true })
  email: string;

  @IsOptional({ groups: [UPDATE] })
  @IsNotEmpty({ groups: [CREATE] })
  @IsBoolean({ always: true })
  isActive: boolean;

  profileId?: number;

  companyId?: number;

  @IsOptional({ groups: [UPDATE] })
  @IsNotEmpty({ groups: [CREATE] })
  @ValidateNested({ always: true })
  profile: UserProfile
}

Packages

  • @nestjsx/crud - core package which provides @Crud() decorator for endpoints generation, global configuration, validation, helper decorators (docs)
  • @nestjsx/crud-request - request builder/parser package which provides RequestQueryBuilder class for a frontend usage and RequestQueryParser that is being used internaly for handling and validating query/path params on a backend side (docs)
  • @nestjsx/crud-typeorm - TypeORM package which provides base TypeOrmCrudService with methods for CRUD database operations (docs)
  • @nestjsx/crud-sequelize - Sequelize package which provides base SequelizeCrudService with methods for CRUD database operations

Documentation

Support

Any support is welcome. At least you can give us a star.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute]. code contributor

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

individual

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

organization organization organization organization organization organization organization organization organization organization

License

MIT

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
3,231
Community Interest
3,003
Number of Forks
400

Maintenance

Commits
11/2110/22010
Last Commit
Open Issues
239
Closed Issues
307
Open Pull Requests
33
Closed Pull Requests
86

Versions

Versions Released
11/2110/2201
Latest Version Released
Sep 17, 2021
Current Tags
latest4.6.27-alpha.0

Contributors

zMotivat0r
zMotivat0r
Commits: 257
Diluka
Diluka
Commits: 43
renovate-bot
renovate-bot
Commits: 25
greenkeeper[bot]
greenkeeper[bot]
Commits: 6
RobotScribe
RobotScribe
Commits: 5
0xflotus
0xflotus
Commits: 5
klalex
klalex
Commits: 4
bestori
bestori
Commits: 3
salomaosnff
salomaosnff
Commits: 3
tbrannam
tbrannam
Commits: 3
roland-chernov
roland-chernov
Commits: 3
jdguzman
jdguzman
Commits: 3
SamiSammour
SamiSammour
Commits: 2
debagger
debagger
Commits: 2
fwoelffel
fwoelffel
Commits: 2