shaonu-authkit 1.0.1 โ 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +133 -0
- package/bin/index.js +0 -1
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaonu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# ๐ shaonu-authkit
|
|
2
|
+
|
|
3
|
+
A CLI tool to instantly scaffold a full **Express + MongoDB** Authentication Service.
|
|
4
|
+
|
|
5
|
+
Just one command and your auth backend is ready!
|
|
6
|
+
|
|
7
|
+
## ๐ Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx shaonu-authkit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## ๐ What It Does
|
|
14
|
+
|
|
15
|
+
When you run the command, it will ask you:
|
|
16
|
+
|
|
17
|
+
- ๐ Project name
|
|
18
|
+
- ๐ MongoDB URI
|
|
19
|
+
- ๐ JWT Secret
|
|
20
|
+
- ๐ Port number
|
|
21
|
+
- ๐ฆ Package manager (npm / yarn / pnpm)
|
|
22
|
+
|
|
23
|
+
Then it will:
|
|
24
|
+
|
|
25
|
+
- โ
Create your project folder
|
|
26
|
+
- โ
Create the full auth service template
|
|
27
|
+
- โ
Generate `.env` file with your values
|
|
28
|
+
- โ
Install all dependencies automatically
|
|
29
|
+
|
|
30
|
+
## ๐ก API Routes
|
|
31
|
+
|
|
32
|
+
| Method | Route | Description | Protected |
|
|
33
|
+
|--------|-------|-------------|-----------|
|
|
34
|
+
| POST | `/api/auth/register` | Register new user | โ |
|
|
35
|
+
| POST | `/api/auth/login` | Login user | โ |
|
|
36
|
+
| POST | `/api/auth/logout` | Logout user | โ
|
|
|
37
|
+
|
|
38
|
+
## ๐ Project Structure
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
your-project/
|
|
42
|
+
โโโ src/
|
|
43
|
+
โ โโโ config/
|
|
44
|
+
โ โ โโโ db.js โ MongoDB connection
|
|
45
|
+
โ โโโ controllers/
|
|
46
|
+
โ โ โโโ auth.controller.js โ Register, Login, Logout logic
|
|
47
|
+
โ โโโ models/
|
|
48
|
+
โ โ โโโ user.model.js โ User schema
|
|
49
|
+
โ โโโ routes/
|
|
50
|
+
โ โโโ auth.routes.js โ API routes
|
|
51
|
+
โ
|
|
52
|
+
โโโ app.js โ Express app entry point
|
|
53
|
+
โโโ .env โ Your environment variables
|
|
54
|
+
โโโ package.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## โ๏ธ Environment Variables
|
|
58
|
+
|
|
59
|
+
After setup, your `.env` file will look like:
|
|
60
|
+
|
|
61
|
+
```env
|
|
62
|
+
PORT=5000
|
|
63
|
+
MONGO_URI=mongodb://localhost:27017/authkit
|
|
64
|
+
JWT_SECRET=your-secret-key
|
|
65
|
+
JWT_EXPIRE=7d
|
|
66
|
+
NODE_ENV=development
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ๐ฆ Dependencies Used
|
|
70
|
+
|
|
71
|
+
| Package | Purpose |
|
|
72
|
+
|---------|---------|
|
|
73
|
+
| `express` | Web framework |
|
|
74
|
+
| `mongoose` | MongoDB ODM |
|
|
75
|
+
| `bcryptjs` | Password hashing |
|
|
76
|
+
| `jsonwebtoken` | JWT tokens |
|
|
77
|
+
| `cookie-parser` | Cookie handling |
|
|
78
|
+
| `dotenv` | Environment variables |
|
|
79
|
+
| `nodemon` | Auto restart in dev |
|
|
80
|
+
|
|
81
|
+
## ๐งช Test Your API
|
|
82
|
+
|
|
83
|
+
### Register
|
|
84
|
+
```bash
|
|
85
|
+
curl -X POST http://localhost:3000/api/auth/register \
|
|
86
|
+
-H "Content-Type: application/json" \
|
|
87
|
+
-d '{"name": "John", "email": "john@example.com", "password": "123456"}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Login
|
|
91
|
+
```bash
|
|
92
|
+
curl -X POST http://localhost:3000/api/auth/login \
|
|
93
|
+
-H "Content-Type: application/json" \
|
|
94
|
+
-d '{"email": "john@example.com", "password": "123456"}'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Logout
|
|
98
|
+
```bash
|
|
99
|
+
curl -X POST http://localhost:3000/api/auth/logout \
|
|
100
|
+
-H "Authorization: Bearer YOUR_TOKEN_HERE"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## ๐ Security Features
|
|
104
|
+
|
|
105
|
+
- โ
Passwords hashed with **bcryptjs** (12 salt rounds)
|
|
106
|
+
- โ
JWT stored in **httpOnly cookie** (XSS protection)
|
|
107
|
+
- โ
**sameSite: strict** cookie (CSRF protection)
|
|
108
|
+
- โ
Password never returned in API responses
|
|
109
|
+
- โ
Token invalidated on logout
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## ๐ Get Started After Setup
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cd your-project-name
|
|
116
|
+
npm run dev
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Server runs on:
|
|
120
|
+
```
|
|
121
|
+
http://localhost:3000
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## ๐จโ๐ป Author
|
|
125
|
+
|
|
126
|
+
Made with โค๏ธ by **Shaonu**
|
|
127
|
+
|
|
128
|
+
- GitHub: [@shaonu](https://github.com/mrsaxena01)
|
|
129
|
+
- NPM: [shaonu-authkit](https://www.npmjs.com/package/shaonu-authkit)
|
|
130
|
+
|
|
131
|
+
## ๐ License
|
|
132
|
+
|
|
133
|
+
MIT License โ free to use in any project!
|
package/bin/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaonu-authkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI to scaffold a full Express + MongoDB Auth Service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"cli",
|
|
18
18
|
"scaffold"
|
|
19
19
|
],
|
|
20
|
+
"license": "MIT",
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"chalk": "^5.3.0",
|
|
22
23
|
"inquirer": "^9.2.0",
|