mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
Updating README
This commit is contained in:
-32
@@ -1,32 +0,0 @@
|
||||
# This is a node.js v8+ JavaScript project
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
|
||||
# Build on Ubuntu Trusty (14.04)
|
||||
# https://docs.travis-ci.com/user/reference/trusty/#javascript-and-nodejs-images
|
||||
dist: xenial
|
||||
sudo: required
|
||||
|
||||
# Use Docker
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- ./install-mongo
|
||||
#- npm install -g mocha
|
||||
|
||||
# https://github.com/greenkeeperio/greenkeeper-lockfile/issues/156
|
||||
install: case $TRAVIS_BRANCH in greenkeeper*) npm i;; *) npm ci;; esac;
|
||||
|
||||
script: "npm run test"
|
||||
|
||||
# Send coverage data to Coveralls
|
||||
after_success:
|
||||
- npm run coverage
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
skip_cleanup: true
|
||||
script:
|
||||
- npx semantic-release
|
||||
@@ -25,6 +25,8 @@ commands like updating and deleting other users.
|
||||
- Winston logging integrated for daily rotated logs and a maximum size of
|
||||
1 megabyte.
|
||||
|
||||
- Linting enforced with [Husky](https://github.com/typicode/husky) and [JavaScript Standard Style rules](https://www.npmjs.com/package/standard).
|
||||
|
||||
## Features
|
||||
This project covers basic necessities of most APIs.
|
||||
* Authentication (passport & jwt)
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
"koa-generic-session": "^2.0.1",
|
||||
"koa-logger": "^3.1.0",
|
||||
"koa-mount": "^4.0.0",
|
||||
"koa-passport": "^4.1.1",
|
||||
"koa-passport": "^4.1.3",
|
||||
"koa-router": "^9.0.1",
|
||||
"koa-static": "^5.0.0",
|
||||
"line-reader": "^0.4.0",
|
||||
|
||||
@@ -6,54 +6,55 @@ class Auth {
|
||||
_this = this
|
||||
this.passport = passport
|
||||
}
|
||||
/**
|
||||
* @apiDefine TokenError
|
||||
* @apiError Unauthorized Invalid JWT token
|
||||
*
|
||||
* @apiErrorExample {json} Unauthorized-Error:
|
||||
* HTTP/1.1 401 Unauthorized
|
||||
* {
|
||||
* "status": 401,
|
||||
* "error": "Unauthorized"
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {post} /auth Authenticate user
|
||||
* @apiName AuthUser
|
||||
* @apiGroup Auth
|
||||
*
|
||||
* @apiParam {String} username User username.
|
||||
* @apiParam {String} password User password.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -H "Content-Type: application/json" -X POST -d '{ "username": "johndoe@gmail.com", "password": "foo" }' localhost:5000/auth
|
||||
*
|
||||
* @apiSuccess {Object} user User object
|
||||
* @apiSuccess {ObjectId} user._id User id
|
||||
* @apiSuccess {String} user.name User name
|
||||
* @apiSuccess {String} user.username User username
|
||||
* @apiSuccess {String} token Encoded JWT
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK
|
||||
* {
|
||||
* "user": {
|
||||
* "_id": "56bd1da600a526986cf65c80"
|
||||
* "username": "johndoe"
|
||||
* },
|
||||
* "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
|
||||
* }
|
||||
*
|
||||
* @apiError Unauthorized Incorrect credentials
|
||||
*
|
||||
* @apiErrorExample {json} Error-Response:
|
||||
* HTTP/1.1 401 Unauthorized
|
||||
* {
|
||||
* "status": 401,
|
||||
* "error": "Unauthorized"
|
||||
* }
|
||||
*/
|
||||
* @apiDefine TokenError
|
||||
* @apiError Unauthorized Invalid JWT token
|
||||
*
|
||||
* @apiErrorExample {json} Unauthorized-Error:
|
||||
* HTTP/1.1 401 Unauthorized
|
||||
* {
|
||||
* "status": 401,
|
||||
* "error": "Unauthorized"
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* @api {post} /auth Authenticate user
|
||||
* @apiName AuthUser
|
||||
* @apiGroup Auth
|
||||
*
|
||||
* @apiParam {String} username User username.
|
||||
* @apiParam {String} password User password.
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -H "Content-Type: application/json" -X POST -d '{ "username": "johndoe@gmail.com", "password": "foo" }' localhost:5000/auth
|
||||
*
|
||||
* @apiSuccess {Object} user User object
|
||||
* @apiSuccess {ObjectId} user._id User id
|
||||
* @apiSuccess {String} user.name User name
|
||||
* @apiSuccess {String} user.username User username
|
||||
* @apiSuccess {String} token Encoded JWT
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK
|
||||
* {
|
||||
* "user": {
|
||||
* "_id": "56bd1da600a526986cf65c80"
|
||||
* "username": "johndoe"
|
||||
* },
|
||||
* "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
|
||||
* }
|
||||
*
|
||||
* @apiError Unauthorized Incorrect credentials
|
||||
*
|
||||
* @apiErrorExample {json} Error-Response:
|
||||
* HTTP/1.1 401 Unauthorized
|
||||
* {
|
||||
* "status": 401,
|
||||
* "error": "Unauthorized"
|
||||
* }
|
||||
*/
|
||||
async authUser (ctx, next) {
|
||||
try {
|
||||
return _this.passport.authenticate('local', (err, user) => {
|
||||
@@ -78,5 +79,24 @@ class Auth {
|
||||
ctx.throw(401)
|
||||
}
|
||||
}
|
||||
|
||||
// async handleAuth (err, user) {
|
||||
// if (err) throw err
|
||||
//
|
||||
// if (!user) {
|
||||
// ctx.throw(401)
|
||||
// }
|
||||
//
|
||||
// const token = user.generateToken()
|
||||
//
|
||||
// const response = user.toJSON()
|
||||
//
|
||||
// delete response.password
|
||||
//
|
||||
// ctx.body = {
|
||||
// token,
|
||||
// user: response
|
||||
// }
|
||||
// }
|
||||
}
|
||||
module.exports = Auth
|
||||
|
||||
Reference in New Issue
Block a user