Priyannik Login Microservice is a lightweight microservice for user authentication and registration. It is built using Cloudflare Workers and provides endpoints for managing users, logging in, and accessing public profiles with structured error handling.
- User login with token-based authentication
- Comprehensive error-code system for debugging
Retrieve the list of all users.
Access: Admin only (should have is_admin
set to true)
Parameters:
token
(required): A unique token generated after login of an admin.
Error Codes:
1601
:token
parameter missing1602
: Token is invalid1603
: Token doesn't belong to an admin account
Get the public profile data of a user.
Parameters:
username
(required): Username of the user.
Error Codes:
1401
:username
parameter missing1402
: User not found
Register a new user.
Request Body:
- JSON object containing
username
,password
andemail
Error Codes:
1001
: Too many accounts on the same IP1002
: Invalid JSON body1003
: Required parameters are not present1004
: Username is invalid (must be alphanumeric, lowercase, 5-20 characters, underscore allowed, no spaces or special characters)1005
: Email is invalid1006
: User already exists
Login as a user and receive a token for further operations.
Request Body:
- JSON object with
username
andpassword
.
Error Codes:
1201
: Invalid JSON body1202
: Required parameters are not present1203
: Username is invalid1204
: Username not found1205
: Password incorrect
The system uses structured error codes to facilitate debugging. The format of the codes is as follows:
ABCD
- A: Module identifier (e.g., 1 for Login/Registration microservice)
- B: Operation type (e.g., Registration (0), Login (2), Logout (3), GetPublicProfile (4), Update Data (5), Get Users (6))
- CD: Specific error
Error Code | Description |
---|---|
1001-1006 |
Errors related to registration operations |
1201-1205 |
Errors related to login operations |
1301-1305 |
Errors related to logout operations |
1401-1402 |
Errors related to retrieving public profiles |
1501-1507 |
Errors related to user data updates |
1601-1603 |
Errors related to admin-only user listing |
- Clone this repository:
git clone https://github.com/priyannik/priyannikloginms.git cd priyannikloginms
- Deploy the Cloudflare Worker using the instructions in the Cloudflare Workers documentation.
Feel free to submit issues or pull requests to contribute to this project. Ensure your code follows the project's structure and coding guidelines.
This project is licensed under the MIT License. See the LICENCE file for details.