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

@pd-solucoes/adonis-basic-crud

v1.0.2

Published

A simple and effective user crud with e-mail

Downloads

12

Readme

Project description

This lib is a fast way to create a User crud with login and mail recovery, build over AdonisJS.

Instalation process

npm:

yarn:

Configuration

This project needs some configurations on host project.

In your .env file is necessary to add soma variables.

In your routes file (./start/routes), need to import routes from LIB.

Database config

Your project need to config database connection, configuration can be found at this link: adonis databse configuration

Befere step above you will need create some migrations.

User:

Tokens:

Mailer config

Your project also needs to install and configure mail providers, configuration can be found at this link: adonis mailer config Project only support this two email providers: SES and SMTP

Lib resources

The lib provides de follow routes:

| HTTP VERB | ROUTE SUFFIX | BODY | AUTHORIZATION | AUTHORIZATION TYPE| |-|-|-|-|-| | POST | /users | {"name": "exampe", "email": "[email protected]","password": "mySecretPassword"} | false | - | | GET | /users | - | true | bearer token| | PUT | /users | {"name": "Update example","email": "[email protected]"} | true | bearer token| | DELETE | /users | - | true | bearer token| | POST | /session | {"email": "[email protected]","password": "mySecretPassword"}| false | - | | POST | /password/forgot | {"email": "[email protected]"} | false | - | | POST | /password/reset | {"token": "token sent to email","new_password": "myNewSecretPassword","new_password_confirmation": "myNewSecretPassword"}| false | - | | POST | /password/change |{"password": "myActualSecretPassword","new_password": "myNewSecretPassword","new_password_confirmation": "MyNewSecretPassword"} | true | bearer token|

This lib provides a auth middleware to use in your host project. On use this middleware it automatically provides a user to request.

User object is like that:

user: {
    id: '1'
}

Example, turns /hello route in private route:

   import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
   import Route from '@ioc:Adonis/Core/Route'

   import {auth} from "@pdsolucoes/adonis-basic-crud"

   Route.post('hello', ({request, response}: HttpContextContract) => {
       return response.ok({
           ok:true
       })
   }).middleware(auth.authenticate)

In order to avoid type errors is recomended use the exported AuthHttpContract from lib.

Example, in hello routes need to show logged user_id:

   import Route from '@ioc:Adonis/Core/Route'

   import {auth, AuthHttpContract} from "@pdsolucoes/adonis-basic-crud"

   Route.post('hello', ({request, response}: AuthHttpContract) => {
       return response.ok({
           ok:true,
           logged_user: request.user.id
       })
   }).middleware(auth.authenticate)

This lib also provide a generic error handler. In order to use this functionality is needed to use StatusCode enum.

Examaple:

  import {GenericExceptionHandler, StatusCode} from "@pdsolucoes/adonis-basic-crud"

  throw new GenericExceptionHandler("My error message", StatusCode.Forbidden)