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

1.4.0 • Public • Published

modern-npm-package

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

Get Started

  1. 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

  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/common

Weekly Downloads

10

Version

1.4.0

License

MIT

Unpacked Size

94.2 kB

Total Files

69

Last publish

Collaborators

  • lamas-running