@runnerpro/common
v1.4.0
Published
A collection of common backend and frontend functions
Downloads
554
Readme
modern-npm-package
An npm packages for common backend and frontend logic between client and dashboard app.
Get Started
- Run
npm install @runnerpro/backend
Functions
parseTimeNumberToString
Return the number of seconds into pretty time format (hh:mm:ss or mm:ss)
- Param: number of seconds
- Param: value for time format (2 === mm:ss || 3 === hh:mm:ss)
- Return: pretty time format
parseTimeStringToNumber
Return the pretty time format into number of seconds
- Param: pretty time format (hh:mm:ss or mm:ss)
- Return: seconds
removeAccent
Return text without accent
- Param: string
- Return: string
sortWorkouts
Return 1 if workout1 should be before workout2 and -1 if not (Calentamiento y Técnica carrera primero)
- Param: workout 1
- Param: workout 2
- Return: number (1, -1, 0)
isCalentamientoByTitle
Return true if workout is by title Calentamiento or Técnica carrera
- Param: workout
- Return: boolean
getPaymentPlanStripe
Return a stripe plan based on price ID
- Param: price ID
- Return: stripe plan { name: string, months: number, price: number, priceFirstMonth?: number }
getNameClientOnly
Return the name of the client without the surname
- Param: full name of client
- Return: name of client
Constants
WORKOUT_TYPE
Specify the types of workouts (CORRER, FUERZA...)
TIPO_APLICACION
Specify the types of aplication user can connect to (STRAVA, GARMIN...)
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.json
in the root directory with the following contents:{ "extension": ["ts"], "spec": "./**/*.spec.ts", "require": "ts-node/register" }
- Create a
tests
folder - Create an
index.spec.ts
file in thetests
folder - Write unit tests in the
index.spec.ts
file to test the code inindex.ts
- Add a
"test"
property in thepackage.json
file and give it a value of"mocha"
- Run
npm test
in your terminal from the root folder of the project