vintage-auth 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/index.js +15 -14
  2. package/package.json +7 -2
package/index.js CHANGED
@@ -1,19 +1,20 @@
1
- const express = require('express')
2
- const cors = require('cors')
3
- const vintageAuth = require('./index') // wait, your first file is the package itself?
1
+ onst express = require('express')
2
+ const mongoose = require('mongoose')
3
+ const authRoutes = require('./routes/auth')
4
4
 
5
- // If your first code block IS index.js, then you use it like this:
5
+ function vintageAuth(config) {
6
+ const { mongoUri, jwtSecret } = config
6
7
 
7
- const app = express()
8
- app.use(cors())
9
- app.use(express.json())
8
+ mongoose.connect(mongoUri)
9
+ .then(() => console.log('✅ vintage-auth: MongoDB connected'))
10
+ .catch(err => console.log('❌ vintage-auth: DB Error', err))
10
11
 
11
- // Mount vintage-auth
12
- const authRouter = vintageAuth({
13
- mongoUri: 'mongodb://localhost:27017/vintage',
14
- jwtSecret: 'supersecret_dev_key'
15
- })
12
+ process.env.VINTAGE_JWT_SECRET = jwtSecret
16
13
 
17
- app.use('/api', authRouter) // now routes = /api/auth/register
14
+ const router = express.Router()
15
+ router.use('/auth', authRoutes)
18
16
 
19
- app.listen(3001, () => console.log('Backend on 3001'))
17
+ return router
18
+ }
19
+
20
+ module.exports = vintageAuth
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "vintage-auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Drop-in auth system for Express apps",
5
5
  "main": "index.js",
6
- "keywords": ["auth", "express", "jwt", "mongodb"],
6
+ "keywords": [
7
+ "auth",
8
+ "express",
9
+ "jwt",
10
+ "mongodb"
11
+ ],
7
12
  "license": "MIT",
8
13
  "dependencies": {
9
14
  "bcryptjs": "^2.4.3",