An npm packages for common backend and frontend logic between client and dashboard app.
- Run
npm install @runnerpro/backend
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
Return the pretty time format into number of seconds
- Param: pretty time format (hh:mm:ss or mm:ss)
- Return: seconds
Return text without accent
- Param: string
- Return: string
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)
Return true if workout is by title Calentamiento or Técnica carrera
- Param: workout
- Return: boolean
Return a stripe plan based on price ID
- Param: price ID
- Return: stripe plan { name: string, months: number, price: number, priceFirstMonth?: number }
Return the name of the client without the surname
- Param: full name of client
- Return: name of client
Specify the types of workouts (CORRER, FUERZA...)
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)
- 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
- 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