JSPM

  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q69722F
  • License MIT

Shared code for nestjs projects

Package Exports

  • nest-shared
  • nest-shared/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nest-shared) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Installation

Install with yarn or npm: yarn or npm:

# yarn
yarn add nest-shared
# npm
npm i nest-shared --save

Import the lib with es6 or cjs:

// es6
import shared from 'nest-shared';
// cjs
const shared = require('nest-shared');

Usage examples:

Constants

#!/usr/bin/env node
import app from './app';
import shared from 'nest-shared';

app.listen(shared.PORT, () => process.stdout.write(`Server is running on port ${shared.PORT}\n`));

Helpers

generateAPIKey
#!/usr/bin/env node
const { generateAPIKey } = require("nest-shared");

console.log(generateAPIKey({
    str: 'Hello World', 
    prefix: 'apk', 
    digest: 'hex',
    size: 8 * 8
 })); // "apk_bd5d70d05e0f3e0da3afa0c82a4faccbd6bda99dfe8af7d916739fbbc98a05b3"
base64Encoder and base64Decoder
#!/usr/bin/env node
const { base64Encoder, base64Decoder } = require("nest-shared");

const encoded = base64Encoder('Hello World')
const decoded = base64Decoder(encoded);

console.log(encoded); // "SGVsbG8gV29ybGQ="
console.log(decoded); // "Hello World"