Giter VIP home page Giter VIP logo

danal's Introduction

danal

danal module for Node.js

version download

js-standard-style

Usage

var http = require('http')
var express = require('express')
var danal = require('../')
var config = require('./config.json')

var uas = new danal.UAS(config.uas)

var app = express()

app.get('/uas',
  function (req, res, next) {
    var token = {
      userid: 'userid',
      session: 'session'
    }
    uas.request(token, function (err, data) {
      if (err) {
        res.json(err)
      }

      // @todo
      // set the tid in the token data
      // ex) updateUser(user, data.tid)

      danal.API.defaults(data, {
        cancel_uri: 'http://127.0.0.1:3001/uas/cancel'
      })
      danal.API.defaults(data, {
        ci_url: config.ci_url
      })
      danal.API.defaults(data, config.user)

      res.locals.uas = data
      next()
    })
  },
  uas.redirect()
)
app.post('/uas/callback',
  uas.receive(),
  function (req, res, next) {
    uas.confirm({
      tid: res.locals.uas.tid,
      userid: 'userid'
    }, function (err, result) {
      res.json({
        uas: res.locals.uas,
        error: err,
        result: result
      })
    })
  }
)
app.post('/uas/cancel',
  uas.receive(),
  function (req, res, next) {
    res.json(res.locals)
  }
)

var port = process.env.PORT || '3001'

app.set(port)
http.createServer(app).listen(port)
// config.json
{
  "ci_url": {
    "basic": "ci logo url : size 115 x 47",
    "mobile": "ci logo url : size 77 x 29"
  },
  "uas": {
    "client_id": "CPID",
    "client_secret": "CPPWD",
    "redirect_uri": "http://127.0.0.1:3001/uas/callback"
  },
  "user": { // optional
    "carrier": "SKT",
    "phonenum": "010-0000-0000",
    "passvalue": "passvalue",
    "yearofbirth": 1982
  }
}
// return data: /uas/callback
{
  "uas": {
    "code": "0000",
    "message": "No information",
    "tid": "201601131221348871382010",
    "cancel_uri": "http://127.0.0.1:3001/uas/cancel",
    "ci_url": "ci logo url",
    "passvalue": "passvalue",
    "yearofbirth": "1982",
    "use_ci": "Y"
  },
  "error": null,
  "result": {
    "code": "0000",
    "message": "No information",
    "ci": "ci string",
    "name": "user name",
    "token": "token",
    "tid": "201601131221348871382010",
    "dateofbirth": "19820504",
    "gender": "1",
    "di": "di string",
    "userid": "userid"
  }
}
// return data: /uas/cancel
{
  "uas": {
    "code": "0000",
    "message": "No information",
    "tid": "201601131224209429051010",
    "cancel_uri": "http://127.0.0.1:3001/uas/cancel",
    "ci_url": "ci logo url",
    "passvalue": "passvalue",
    "yearofbirth": "1982",
    "use_ci": "Y"
  }
}

carrier

  • SKT
  • KTF
  • LGT
  • MVNO

Documentation

See the documentation

Release History

See the changelog

LICENSE

danal is licensed under the MIT license.

danal's People

Contributors

egg- avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.