Hashing library for Nest.Js

Overview

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Hashing library for NestJS.

Installation

$ npm install nestjs-hash

or

$ yarn add nestjs-hash

Hou to use

1 - first add hash module in import for your module

Using with native hash

  import { HashModule } from 'nestjs-hash';

  @Module({
    imports: [HashModule.forRoot({ type: 'sha256' })],
  })
  export default UsersModule;

or external library hash

  import { HashModule } from 'nestjs-hash';

  @Module({
    imports: [HashModule.forRoot({ type: 'bcrypt', rounds: 16 })],
  })
  export default UsersModule;

Attention to use bcrypt or more libraries you need to add them as dependencies to your project.

  • bcrypt
$ npm install bcrypt
  • argon2
$ npm install argon2

2 - second uses dependency injection to add the hash service to your service

  @Injectable()
  export class UsersService() {
    constructor(
      private readonly hashService: HashService,
      private readonly usersRepository: UsersRepository
    ) {}

    public async createUser(data) {
      const passwordHash = await this.hashService.hash(data.password);
      const user = await this.usersRepository.create({
        ...data,
        password: passwordHash
      });
      return user;
    }
  };

Author

Created with more love by Arthur Reis

License

MIT licensed.

You might also like...

Project implements decorators for oak like Nest.js.

oak decorators Project implements decorators like implementation of Nest.js for Deno's web framework oak. Usage The following are the core files that

Dec 5, 2022

Nest accessory developed with HAP-NodeJS to allow devices into HomeKit

Nest_accfactory This is a HAP-NodeJS accessory I have developed to allow Nest devices to be used with HomeKit including having support for HomeKit Sec

Oct 9, 2022

A Nest rewrite of crystal, the SOS Discord bot

crystal-nest A Nest rewrite of crystal, the SOS Discord bot Explore the docs » Report Bug · Request Feature Table of Contents About The Project Built

Dec 22, 2022

next + nest webchat repository

next-webchat next + nest webchat repository 在线网络聊天室 前端:next + React 服务端渲染,使用@reduxjs/toolkit ++ hook 搭配使用 react-redux 使得状态管理更易上手, 外加socket.io-client 实

Dec 20, 2022

A Nest.js API for a restaurant storage management system.

Restaurant Storage Management System Description A Nest.js API for a restaurant storage management system. Installation $ yarn install Database Seeder

Sep 12, 2022

Tile38 module for Nest framework (node.js)

Description Tile38 module for Nest. This package is based on Tile38-ts, so visit its documentation for any questions about the API. Installation $ npm

Sep 22, 2022

Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Dec 24, 2022

A JavaScript library built on top of the Faker.JS library. It generates massive amounts of fake data in the browser and node.js.

Blaver - generate massive amounts of fake data in the browser and node.js Blaver is a JavaScript library built on top of the Faker.JS library. It gene

Dec 30, 2022

A small javascript DOM manipulation library based on Jquery's syntax. Acts as a small utility library with the most common functions.

Quantdom JS Quantdom is a very small (about 600 bytes when ran through terser & gzipped) dom danipulation library that uuses a Jquery like syntax and

Aug 16, 2022
Owner
Arthur Reis
Desenvolvedor Full-Stack apaixonado por tecnologia, sempre querendo evoluir suas habilidades e adquiri novas experiencias.
Arthur Reis
The NEST Prize Bot is a tool for the activity of the NEST community.

NEST Prize Bot The NEST Prize Bot is a tool developed by our team for the activity of the NEST community. It can record the receipt of Prize and expor

NEST Protocol 403 Dec 20, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Nest multiple blocks inside lists of any kind of list (ordered, unordered, no marker, etc), or do away with list markers and use it like a repeater!

Nest multiple blocks inside lists of any kind of list (ordered, unordered, no marker, etc), or do away with list markers and use it like a repeater!

Rani 15 Dec 26, 2022
OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

A progressive Node.js framework for building efficient and scalable server-side applications. Description OpenAPI (Swagger) module for Nest. Installat

nestjs 1.3k Jan 6, 2023
Nest.js project used it implement login page functionality.

Basic Login Backend (API) Description This project is the backend (API) portion of a basic login application. It calls a local frontend project basic-

Chad D.S 2 Mar 21, 2022
Plugin to run NestJS Apps from Nest Monorepo

Serverless Nest Monorepo Plugin Plugin that adds support to run NestJS Apps from Nest Monorepo, which is set up using Nest CLI with several microservi

Blub Blub 13 Dec 1, 2022
API of my readings, developed in Nest.js, MongoDB, Nginx and Dockerized

My Readings step by step for configuration with docker OBS: required docker and docker-compose cp -r .env.sample .env docker-compose up example what t

William Koller 30 Jul 1, 2022