Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crud): TypeOrm Cache was not working #688

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, u
patreon: # Replace with a single Patreon username
open_collective: nestjsx
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/@nestjsx/crud
tidelift: npm/@rewiko/crud
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
Expand Down
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
<br />

<div align="center">
<a href="https://travis-ci.org/nestjsx/crud">
<img src="https://github.com/nestjsx/crud/workflows/Tests/badge.svg" alt="Build" />
<a href="https://travis-ci.org/rewiko/crud">
<img src="https://github.com/rewiko/crud/workflows/Tests/badge.svg" alt="Build" />
</a>
<a href="https://coveralls.io/github/nestjsx/crud?branch=master">
<img src="https://coveralls.io/repos/github/nestjsx/crud/badge.svg" alt="Coverage" />
<a href="https://coveralls.io/github/rewiko/crud?branch=master">
<img src="https://coveralls.io/repos/github/rewiko/crud/badge.svg" alt="Coverage" />
</a>
<a href="https://github.com/nestjsx/crud/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/nestjsx/crud.svg" alt="License" />
<a href="https://github.com/rewiko/crud/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/rewiko/crud.svg" alt="License" />
</a>
<a href="https://www.npmjs.com/package/@nestjsx/crud">
<img src="https://img.shields.io/npm/v/@nestjsx/crud.svg" alt="npm version" />
<a href="https://www.npmjs.com/package/@rewiko/crud">
<img src="https://img.shields.io/npm/v/@rewiko/crud.svg" alt="npm version" />
</a>
<a href="https://www.npmjs.com/org/nestjsx">
<img src="https://img.shields.io/npm/dm/@nestjsx/crud.svg" alt="npm downloads" />
<img src="https://img.shields.io/npm/dm/@rewiko/crud.svg" alt="npm downloads" />
</a>
<a href="https://npm.packagequality.com/#?package=@nestjsx%2Fcrud">
<img src="https://npm.packagequality.com/shield/%40nestjsx%2Fcrud.svg" alt="Package Quality" />
Expand All @@ -33,13 +33,13 @@
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs welcome" />
</a>
<a href="https://github.com/marmelab/awesome-rest#nodejs">
<img src="https://raw.githubusercontent.com/nestjsx/crud/master/img/awesome-rest.svg?sanitize=true" alt="Awesome REST" />
<img src="https://raw.githubusercontent.com/rewiko/crud/master/img/awesome-rest.svg?sanitize=true" alt="Awesome REST" />
</a>
<a href="https://github.com/juliandavidmr/awesome-nestjs#components--libraries">
<img src="https://raw.githubusercontent.com/nestjsx/crud/master/img/awesome-nest.svg?sanitize=true" alt="Awesome Nest" />
<img src="https://raw.githubusercontent.com/rewiko/crud/master/img/awesome-nest.svg?sanitize=true" alt="Awesome Nest" />
</a>
<a href="https://github.com/nestjs/nest">
<img src="https://raw.githubusercontent.com/nestjsx/crud/master/img/nest-powered.svg?sanitize=true" alt="Nest Powered" />
<img src="https://raw.githubusercontent.com/rewiko/crud/master/img/nest-powered.svg?sanitize=true" alt="Nest Powered" />
</a>
<a href="#individuals" alt="Sponsors on Open Collective">
<img src="https://opencollective.com/nestjsx/backers/badge.svg" />
Expand All @@ -52,7 +52,7 @@
<div align="center">
<sub>Built with :purple_heart: by
<a href="https://twitter.com/MichaelYali">@MichaelYali</a> and
<a href="https://github.com/nestjsx/crud/graphs/contributors">
<a href="https://github.com/rewiko/crud/graphs/contributors">
Contributors
</a>
<div align="center">
Expand All @@ -62,7 +62,7 @@

<br />

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.
We believe that everyone who's working with NestJs and building some RESTful services and especially some CRUD functionality will find `@rewiko/crud` microframework very useful.

## Features

Expand All @@ -88,16 +88,31 @@ We believe that everyone who's working with NestJs and building some RESTful ser

## Packages

- [**@nestjsx/crud**](https://www.npmjs.com/package/@nestjsx/crud) - core package which provides `@Crud()` decorator for endpoints generation, global configuration, validation, helper decorators ([docs](https://github.com/nestjsx/crud/wiki/Controllers#description))
- [**@nestjsx/crud-request**](https://www.npmjs.com/package/@nestjsx/crud-request) - request builder/parser package which provides `RequestQueryBuilder` class for a frontend usage and `RequestQueryParser` that is being used internally for handling and validating query/path params on a backend side ([docs](https://github.com/nestjsx/crud/wiki/Requests#frontend-usage))
- [**@nestjsx/crud-typeorm**](https://www.npmjs.com/package/@nestjsx/crud-typeorm) - TypeORM package which provides base `TypeOrmCrudService` with methods for CRUD database operations ([docs](https://github.com/nestjsx/crud/wiki/ServiceTypeorm))
- [**@rewiko/crud**](https://www.npmjs.com/package/@rewiko/crud) - core package which provides `@Crud()` decorator for endpoints generation, global configuration, validation, helper decorators ([docs](https://github.com/rewiko/crud/wiki/Controllers#description))
- [**@rewiko/crud-request**](https://www.npmjs.com/package/@rewiko/crud-request) - request builder/parser package which provides `RequestQueryBuilder` class for a frontend usage and `RequestQueryParser` that is being used internally for handling and validating query/path params on a backend side ([docs](https://github.com/rewiko/crud/wiki/Requests#frontend-usage))
- [**@rewiko/crud-typeorm**](https://www.npmjs.com/package/@rewiko/crud-typeorm) - TypeORM package which provides base `TypeOrmCrudService` with methods for CRUD database operations ([docs](https://github.com/rewiko/crud/wiki/ServiceTypeorm))

## Documentation

- :dart: [General Information](https://github.com/nestjsx/crud/wiki#why)
- :video_game: [CRUD Controllers](https://github.com/nestjsx/crud/wiki/Controllers#description)
- :horse_racing: [CRUD ORM Services](https://github.com/nestjsx/crud/wiki/Services#description)
- :trumpet: [Handling Requests](https://github.com/nestjsx/crud/wiki/Requests#description)
- :dart: [General Information](https://github.com/rewiko/crud/wiki#why)
- :video_game: [CRUD Controllers](https://github.com/rewiko/crud/wiki/Controllers#description)
- :horse_racing: [CRUD ORM Services](https://github.com/rewiko/crud/wiki/Services#description)
- :trumpet: [Handling Requests](https://github.com/rewiko/crud/wiki/Requests#description)

## Build library and run tests

```
yarn bootstrap
yarn build
docker-compose up -d
yarn test:coverage
```

## Make a release

- Merge a PR on master.
- Pull and checkout master
- Run `yarn pub` - this will publish on the npm repo (need to be logged under rewiko `yarn login`)

## Support

Expand All @@ -108,7 +123,7 @@ Any support is welcome. At least you can give us a star :star:
### Code Contributors

This project exists thanks to all the people who contribute. [[Contribute](CODE_OF_CONDUCT.md)].
<a href="https://github.com/nestjsx/crud/graphs/contributors"><img src="https://opencollective.com/nestjsx/contributors.svg?width=890&button=false" /></a>
<a href="https://github.com/rewiko/crud/graphs/contributors"><img src="https://opencollective.com/nestjsx/contributors.svg?width=890&button=false" /></a>

### Financial Contributors

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/companies/companies.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Crud } from '@rewiko/crud';

import { Company } from './company.entity';
import { CompaniesService } from './companies.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/companies/companies.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { TypeOrmCrudService } from '@rewiko/crud-typeorm';

import { Company } from './company.entity';

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/companies/company.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CrudValidationGroups } from '@nestjsx/crud';
import { CrudValidationGroups } from '@rewiko/crud';
import { Entity, Column, OneToMany, PrimaryGeneratedColumn, DeleteDateColumn } from 'typeorm';
import {
IsOptional,
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/companies/responses/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SerializeOptions } from '@nestjsx/crud';
import { SerializeOptions } from '@rewiko/crud';
import { GetCompanyResponseDto } from './get-company-response.dto';

export const serialize: SerializeOptions = {
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/devices/device.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
import { IsOptional, IsString, IsUUID } from 'class-validator';
import { CrudValidationGroups } from '@nestjsx/crud';
import { CrudValidationGroups } from '@rewiko/crud';

const { CREATE, UPDATE } = CrudValidationGroups;

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/devices/devices.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Crud } from '@rewiko/crud';

import { Device } from './device.entity';
import { DevicesService } from './devices.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/devices/devices.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { TypeOrmCrudService } from '@rewiko/crud-typeorm';

import { Device } from './device.entity';

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/devices/response/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SerializeOptions } from '@nestjsx/crud';
import { SerializeOptions } from '@rewiko/crud';
import { DeleteDeviceResponseDto } from './delete-device-response.dto';

export const serialize: SerializeOptions = {
Expand Down
8 changes: 4 additions & 4 deletions integration/crud-typeorm/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { CrudConfigService } from '@nestjsx/crud';
import { CrudConfigService } from '@rewiko/crud';
import { USER_REQUEST_KEY } from './constants';

// Important: load config before (!!!) you import AppModule
// https://github.com/nestjsx/crud/wiki/Controllers#global-options
// https://github.com/rewiko/crud/wiki/Controllers#global-options
CrudConfigService.load({
auth: {
property: USER_REQUEST_KEY,
Expand All @@ -23,8 +23,8 @@ async function bootstrap() {
app.useGlobalFilters(new HttpExceptionFilter());

const options = new DocumentBuilder()
.setTitle('@nestjsx/crud-typeorm')
.setDescription('@nestjsx/crud-typeorm')
.setTitle('@rewiko/crud-typeorm')
.setDescription('@rewiko/crud-typeorm')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, options);
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/notes/notes.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Crud } from '@rewiko/crud';

import { Note } from './note.entity';
import { NotesService } from './notes.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/orm.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from 'path';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { isNil } from '@nestjsx/util';
import { isNil } from '@rewiko/util';

const type = (process.env.TYPEORM_CONNECTION as any) || 'postgres';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud, CrudAuth } from '@nestjsx/crud';
import { Crud, CrudAuth } from '@rewiko/crud';

import { User } from '../users/user.entity';
import { UserProject } from './user-project.entity';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/projects/project.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IsDefined,
IsBoolean,
} from 'class-validator';
import { CrudValidationGroups } from '@nestjsx/crud';
import { CrudValidationGroups } from '@rewiko/crud';

import { BaseEntity } from '../base-entity';
import { Company } from '../companies/company.entity';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/projects/projects.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Crud } from '@rewiko/crud';

import { Project } from './project.entity';
import { ProjectsService } from './projects.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/projects/projects.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { TypeOrmCrudService } from '@rewiko/crud-typeorm';

import { Project } from './project.entity';

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/projects/user-projects.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { TypeOrmCrudService } from '@rewiko/crud-typeorm';

import { UserProject } from './user-project.entity';

Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/seeds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClassType } from '@nestjsx/util';
import { ClassType } from '@rewiko/util';
import { plainToClass } from 'class-transformer';
import { MigrationInterface, Repository, QueryRunner } from 'typeorm';
import { Company } from './companies';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/users/me.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Crud, CrudAuth } from '@nestjsx/crud';
import { Crud, CrudAuth } from '@rewiko/crud';

import { User } from './user.entity';
import { UsersService } from './users.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/users/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { CrudValidationGroups } from '@nestjsx/crud';
import { CrudValidationGroups } from '@rewiko/crud';

import { BaseEntity } from '../base-entity';
import { UserProfile } from '../users-profiles/user-profile.entity';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CrudRequest,
ParsedRequest,
Override,
} from '@nestjsx/crud';
} from '@rewiko/crud';

import { User } from './user.entity';
import { UsersService } from './users.service';
Expand Down
2 changes: 1 addition & 1 deletion integration/crud-typeorm/users/users.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { TypeOrmCrudService } from '@nestjsx/crud-typeorm';
import { TypeOrmCrudService } from '@rewiko/crud-typeorm';

import { User } from './user.entity';

Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = {
],
coverageThreshold: {
global: {
branches: 98,
functions: 98,
branches: 97,
functions: 97,
lines: 98,
statements: 98,
},
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "5.0.0-alpha.3",
"version": "5.0.13",
"command": {
"publish": {
"message": "chore: release"
Expand Down
2 changes: 1 addition & 1 deletion package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const names = ['util', 'crud-request', 'crud', 'crud-typeorm'];

const getBuildCmd = (pkg) => {
const str = 'npx lerna run build';
const scoped = (name) => `--scope @nestjsx/${name}`;
const scoped = (name) => `--scope @rewiko/${name}`;
return pkg ? `${str} ${scoped(pkg)}` : getSeries(names.map((name) => `build.${name}`));
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@nestjsx/crud",
"name": "@rewiko/crud",
"version": "4.0.0",
"description": "Nest CRUD for RESTful APIs",
"license": "MIT",
Expand Down