https://github.com/frenchbread/server.js-auth-example
PassportJS + JWT + ServerJS
https://github.com/frenchbread/server.js-auth-example
Last synced: about 1 year ago
JSON representation
PassportJS + JWT + ServerJS
- Host: GitHub
- URL: https://github.com/frenchbread/server.js-auth-example
- Owner: frenchbread
- License: mit
- Created: 2017-11-07T04:12:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T13:12:06.000Z (over 8 years ago)
- Last Synced: 2025-03-16T17:45:26.634Z (about 1 year ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# server.js-auth-example
> [PassportJS](https://github.com/jaredhanson/passport) + [JWT](https://github.com/auth0/node-jsonwebtoken) + [ServerJs](https://github.com/franciscop/server)
### Setup
> **NOTE:** requires MongoDB up and running
```bash
# Clone repo
❯ git clone https://github.com/frenchbread/server.js-auth-example.git && cd server.js-auth-example
# Install dependencies
❯ yarn install
# or
❯ npm install
# Start server
❯ node server.js
```
### Usage
#### Register new user
##### `POST` - `/register`
```bash
❯ curl -H "Content-Type: application/json" -X POST -d '{"email":"some@mail.com","password":"somepassword"}' http://localhost:3030/register
# Server reply
{"ok":true,"message":"Successfully created new user."}
```
#### Login
##### `POST` - `/login`
```bash
❯ curl -H "Content-Type: application/json" -X POST -d '{"email":"some@mail.com","password":"somepassword"}' http://localhost:3030/login
# Server reply
{"ok":true,"data":{"user":{"_id":"5a0129ec1cc973ec2e92b985","email":"some@mail.com"},"token":""}}
```
#### Verify
##### `GET` - `/verify`
```bash
❯ curl -H 'Authorization: JWT ' -X GET http://127.0.0.1:3030/verify
# Server reply
{"ok":true,"user":{"_id":"5a0129ec1cc973ec2e92b985","email":"some@mail.com","__v":0}}
```
### License
[MIT](https://github.com/frenchbread/server.js-auth-example/blob/master/LICENSE)