@runnerpro/backend v1.9.3
modern-npm-package
An npm packages for common backend logic between client and dashboard app.
Get Started
- 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
- Create a folder with the name of functionality and index.ts inside. Write the function and export it.
- In main index.ts (the one inside src), import and export it
- Change the version number of the package (using this convenction)
- Run
npm login - Run
npm run publish
Testing
- Install developer dependencies using the following command in your terminal
npm i -D mocha @types/mocha chai @types/chai ts-node - Create a new file
.mocharc.jsonin the root directory with the following contents:{ "extension": ["ts"], "spec": "./**/*.spec.ts", "require": "ts-node/register" } - Create a
testsfolder - Create an
index.spec.tsfile in thetestsfolder - Write unit tests in the
index.spec.tsfile to test the code inindex.ts - Add a
"test"property in thepackage.jsonfile and give it a value of"mocha" - Run
npm testin your terminal from the root folder of the project
9 months ago
8 months ago
8 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
7 months ago
9 months ago
6 months ago
8 months ago
10 months ago
6 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
8 months ago
12 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
7 months ago
9 months ago
7 months ago
10 months ago
7 months ago
7 months ago
9 months ago
9 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
6 months ago
9 months ago
6 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
5 months ago
8 months ago
8 months ago
6 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
7 months ago
9 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
9 months ago
6 months ago
6 months ago
9 months ago
6 months ago
6 months ago
9 months ago
6 months ago
6 months ago
6 months ago
6 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago