📅  最后修改于: 2023-12-03 14:39:02.888000             🧑  作者: Mango
Adonis Auth Register is a powerful package that allows developers to easily add user registration functionality to their AdonisJS applications. The package is written in TypeScript, making it easy to use and understand for developers who are already familiar with the language.
To install Adonis Auth Register, run the following command:
npm i @siddharthkp/adonis-auth-register
To get started with Adonis Auth Register, you need to add the provider to your AdonisJS application. You can do this by adding the following line to the start/app.ts
file:
import AuthRegisterProvider from '@siddharthkp/adonis-auth-register/providers/AuthRegisterProvider'
const providers = [
// ...
AuthRegisterProvider,
]
Next, you will also need to create a controller that handles the registration process for your application. To do this, you can use the adonis make:controller
command to generate a new controller:
adonis make:controller Auth/RegisterController
Then, update the newly created RegisterController
to use the AuthRegister
helper:
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { AuthRegister } from '@siddharthkp/adonis-auth-register'
export default class RegisterController {
public async register({ request, response }: HttpContextContract) {
await AuthRegister.register(request, response)
}
}
Finally, you just need to add a new route to your application that maps to the register
method of your new RegisterController
:
import Route from '@ioc:Adonis/Core/Route'
Route.post('/register', 'Auth/RegisterController.register')
Adonis Auth Register is a great package for beginners and experienced developers alike who want to quickly and easily add user registration functionality to their AdonisJS applications. With its TypeScript integration and simple interface, it is a must-have for any AdonisJS developer.