npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nest-rest-framework

v1.0.2

Published

<p align="center"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAACqCAYAAABxozHnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAGqWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4b

Downloads

9

Readme

Installation

Coming Soon

$ npm install --save nest-rest-framework nest-rest-framework-[typeorm|mongoose]

Nest REST Framework Concepts

Controllers

The foundational belief of the NRF design is that the controller should be as absent of code and logic as possible. The controller's job in this pattern is the wire together pieces that do the real work: ViewSets, Transformers, and Hooks.

ViewSets

The duty of the viewset is to manage the interactions with the data storage layer by implementing the ViewSet base. This logic should be free of mapping logic (transformers) or business logic (hooks). Future state intention is that Nest REST Framework offers quick-start ViewSets for tools such as TypeORM and Mongoose.

Transformers

Transformers are object mappers. NRF has two types of transformers: data transformers and request transformers. Future state intention is that these transformers are optional for use-cases such as prototypes or data-viewer style apps -- this will allow for a very quick spin-up of full REST APIs.

Data Transformers

Data transformers should map the stored data object into a web API-friendly response format. Typically these types of objects are JSON interfaces. Input: database object. Output: web API response.

Request Transformers

Request transformers should map the incoming data request into the stored data object. Input: web API request. Output: database object.

Hooks

Hooks are event registrations for specific use-cases. NRF has three types of hooks: auth hooks, save hooks, and error hooks.

Auth Hooks

Auth hooks are responsible for validating the request for authorization and authentication. For instance, is the user logged in? Does this user have access to take CRUD actions against this particular entity? Can data only be managed on Tuesdays? Auth hooks are agnostic and allow for any sort of validation and verification.

Save Hooks

Save hooks are executed whenever data changes are made.

Error hooks

Error hooks are executed whenever an error occurs during the controller request lifecycle. Creating an error hook allows for functionality such as custom responses, support ticket logging, or process logging.

Creating your first API

  1. Create your data model class
export class Todo {
  id: number;
  details: string;
  complete: boolean;
  1. Create a data transformer class.
export class TodoDataTransformer extends Transformer<Todo, TodoDto> {
  transform(input: Todo): TodoDto {
    const dto = {} as Todo;
    dto.id = input.id;
    dto.details = input.details;
    dto.complete = input.complete;
    return dto;
  }
}
  1. Create a request transformer class.
export class TodoRequestTransformer extends Transformer<TodoDto, Todo> {
  transform(input: TodoDto): Todo {
    const entity = new Todo();
    entity.id = input.id;
    entity.details = input.details;
    entity.complete = input.complete;
    return entity;
  }
}
  1. Create a viewset class.
export class TodoViewSet extends ViewSet<
  number,
  Todo
> {
}
  1. Create your controller.
@Controller('todo')
export class TodoController extends RestController<
  number,
  Todo,
  TodoDto,
  TodoDto
> {
  constructor(
    viewset: TodoViewSet,
    requestTransformer: TodoRequestTransformer,
    dataTransformer: TodoDataTransformer,
  ) {
    super({
      enableBatch: true,
      viewset,
      requestTransformer,
      dataTransformer,
    });
  }
}

Support

Nest REST Framework is an MIT-licensed open source project.

Committing

Committing to this project requires Commit messages to be formatted according to the Angular conventional-changelog

Stay in touch

License

Nest REST Framework is MIT licensed.