@nuid/sdk-nodejs
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

NuID SDK for Node.js

This repo provides an npm package for interacting with NuID APIs within Node.js applications.

Read the latest package docs or checkout the platform docs for API docs, guides, video tutorials, and more.

This package is written with typescript so you should be able to get valid type definitions in your editor when importing this package. Using typescript is not a requirement to use this package.

Install

With npm:

npm install @nuid/sdk-nodejs

Or with yarn:

yarn add @nuid/sdk-nodejs

Usage

Example server endpoint handled by express.

For a more detailed example visit the Integrating with NuID guide and its accompanying examples repository with a Node.js + express.js example .

const express = require('express')
const nuidApi = require('@nuid/sdk-nodejs').default({
  auth: { apiKey: process.env.NUID_API_KEY }
})

const app = express()

// See links above for more complete examples
app.post('/register', (req, res) => {
  return Promise.resolve(req.body.verifiedCredential)
    .then(nuidApi.auth.credentialCreate)
    .then(res  => res.parsedBody['nu/id'])
    .then(nuid => User.create({ nuid, email, first_name, last_name }))
    .then(user => res.json({ user }).send(201))
    .catch(err => res.json({ errors: ["Failed to create credential"] }).send(500))
})

app.listen(process.env.PORT)

Package Sidebar

Install

npm i @nuid/sdk-nodejs

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

45.5 kB

Total Files

16

Last publish

Collaborators

  • nolan330