Commencer simplifies the integration of authentication into your projects, offering a quick and hassle-free setup.
Step 1 : For Install the package via npm
npx commencer
Or Clone the repo directly
Step 2 :
Configure your MySQL database URL in the .env
file under COMMENCER_DATABASE_URL
Step 3 : Generate Prisma files:
npx prisma generate
Step 4 : Deploy migrations:
npx prisma migrate deploy
Contributions are welcome!😃 Follow these steps to contribute:
-
Fork the repository.
-
Create a new branch for your feature or bug fix.
-
Stage and commit your changes:
git add <file-path>
git commit -m "Detailed message about changes"
- Push to your branch and create a pull request.
To stage changes:
git add <file-path>
To commit changes:
git commit # opens vim editor
For a simple commit message (not recommended):
git commit -m "<message>"
- After registration, users will receive an OTP via email.
- Users must verify the OTP to complete the registration.
- Re-registration is not allowed if the email is already in the database, regardless of OTP verification status.
The /src/routes/user/index.ts
file defines several authentication-related endpoints. Some routes listed below are prefixed with /auth/
.
-
Input:
userID
(string): The user’s ID.idType
(string): The user’s ID Type (Can bemobile
/email
).name
(string): The user's Name.
-
Controller:
Registers a new user and sends an OTP for email/mobile as mentioned for verification.
-
Input:
userID
(string): The user’s ID.password
(string): The user’s password.
-
Controller:
Authenticates the user and returns a session token on successful login.
- Input:
otp
(number): The otp required.userID
(string): The user’s ID.password
(string): The user’s password.
- Controller:
Resets the password for the existing user using Inputs mentioned (usingPUT
method).
-
Input:
otp
(string): The otp required.userID
(string): The user’s ID.password
(string): The user’s password.
-
Controller:
Creates a password for user’s account (if they have never set one before) using a valid OTP (via thePUT
method).
To contribute, create a discussion thread to clarify processes and suggest improvements.
Feel free to open issues or discussions if you need assistance or encounter any problems. Contributions and suggestions are highly encouraged to improve the repository.