@runnerpro/backend
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

modern-npm-package

An npm packages for common backend logic between client and dashboard app.

Get Started

  1. Run npm install @runnerpro/backend

Functions

query

Connection with the PostgresSQL database

  • Param: string with PostgreSQL query
  • Param: array of values
  • Return: promise of array of values (each item is a row of the table)

batchQuery

Connection with PostgreSQL database in batches. Use for faster query execution when we need to execute many queries.

  • Param: Array of queries
    • query: string with PostgreSQL query
    • values: array of values
  • Param?: length of promises wait together. Default 5
  • Return: promise (without values)

sendMail

Send mail with company logo and template

  • Param: { subject, title, body, to, link?, attachments?, bcc? }

    • subject: title of the mail
    • body: text inside card
    • to: array of mails. In DEV and SBX the value is taken from .env GMAIL_EMAIL_USER
    • link: button to redirect to the app. { text: text inside button, url: path (after runnerpro.com) }
    • attachments: array of files to attach. { filename: name and extension of file, path: path of file, cid?: identifier to insert inside the body (<img src="cid:__cid__" />) }
    • bcc: array of mails to send via bcc
  • Return: promise (without values)

sendNotification

Send web or native notification to client: TODO

  • Param: Array of queries { query: string with PostgreSQL query, values: array of values }
  • Param?: length of promises wait together. Default 5
  • Return: promise (without values)

sleep

Wait X miliseconds to execute next line

  • Param: number of miliseconds of the promise
  • Return: promise (without values)

Deploy new version

  1. Create a folder with the name of functionality and index.ts inside. Write the function and export it.
  2. In main index.ts (the one inside src), import and export it
  3. Change the version number of the package (using this convenction)
  4. Run npm login
  5. Run npm run publish

Testing

  1. Install developer dependencies using the following command in your terminal npm i -D mocha @types/mocha chai @types/chai ts-node
  2. Create a new file .mocharc.json in the root directory with the following contents:
    {
      "extension": ["ts"],
      "spec": "./**/*.spec.ts",
      "require": "ts-node/register"
    }
  3. Create a tests folder
  4. Create an index.spec.ts file in the tests folder
  5. Write unit tests in the index.spec.ts file to test the code in index.ts
  6. Add a "test" property in the package.json file and give it a value of "mocha"
  7. Run npm test in your terminal from the root folder of the project

Readme

Keywords

none

Package Sidebar

Install

npm i @runnerpro/backend

Weekly Downloads

7

Version

1.1.3

License

MIT

Unpacked Size

70.1 kB

Total Files

68

Last publish

Collaborators

  • lamas-running