npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ynov-toulouse-b3-info-live-score-api

v1.0.4

Published

```npm install ynov-toulouse-b3-info-live-score-api```

Downloads

3

Readme

Live Score API

Install

npm install ynov-toulouse-b3-info-live-score-api

Usage

Asynchronous API

Import

import { liveScoreRepositoryAsync } from 'ynov-toulouse-b3-info-live-score-api';

Count

liveScoreRepositoryAsync.count()
  .then(count => console.log(count))
  .catch(error => console.error(error));

Find all

liveScoreRepositoryAsync.findAll()
  .then(items => console.log(items))
  .catch(error => console.error(error));

Find by page

const pageIndex = 0;
const pageSize = 20;
liveScoreRepositoryAsync.findByPage(pageIndex, pageSize)
  .then(items => console.log(items))
  .catch(error => console.error(error));

Find by id

const id = 120;
liveScoreRepositoryAsync.findById(id)
  .then(item => console.log(item))
  .catch(error => console.error(error));

Create

const item = {
  date: '2017-08-03T20:45:00.000+01:00',
  homeTeamName: 'Barcelona',
  awayTeamName: 'Paris Saint-Germain',
  homeTeamScore: 6,
  awayTeamScore: 1,
};
liveScoreRepositoryAsync.create(item)
  .then(items => console.log(items))
  .catch(error => console.error(error));

Update

const id = 121;
const partialItem = {
  homeTeamName: 'FCB',
  awayTeamName: 'PSG',
};
liveScoreRepositoryAsync.update(id, partialItem)
  .then(items => console.log(items))
  .catch(error => console.error(error));

Replace

const id = 121;
const item = {
  date: '2017-08-03T20:45:00.000+01:00',
  homeTeamName: 'Barcelona',
  awayTeamName: 'Paris Saint-Germain',
  homeTeamScore: 6,
  awayTeamScore: 1,
};
liveScoreRepositoryAsync.replace(id, item)
  .then(items => console.log(items))
  .catch(error => console.error(error));

Remove

const id = 121;
liveScoreRepositoryAsync.remove(id)
  .then(() => console.log('removed'))
  .catch(error => console.error(error));

Synchronous API

import { liveScoreRepositorySync } from 'ynov-toulouse-b3-info-live-score-api';

Count

try {
  const count = liveScoreRepositorySync.count();
  console.log(count);
} catch (error) {
  console.error(error);
}

Find all

try {
  const items = liveScoreRepositorySync.findAll();
  console.log(items);
} catch (error) {
  console.error(error);
}

Find by page

const pageIndex = 0;
const pageSize = 20;
try {
  const items = liveScoreRepositorySync.findByPage(pageIndex, pageSize);
  console.log(items);
} catch (error) {
  console.error(error);
}

Find by id

const id = 120;
try {
  const item = liveScoreRepositorySync.findById(id);
  console.log(item);
} catch (error) {
  console.error(error);
}

Create

const item = {
  date: '2017-08-03T20:45:00.000+01:00',
  homeTeamName: 'Barcelona',
  awayTeamName: 'Paris Saint-Germain',
  homeTeamScore: 6,
  awayTeamScore: 1,
};
try {
  const createdItem = liveScoreRepositorySync.create(item);
  console.log(createdItem);
} catch (error) {
  console.error(error);
}

Update

const id = 121;
const partialItem = {
  homeTeamName: 'FCB',
  awayTeamName: 'PSG',
};
try {
  const updatedItem = liveScoreRepositorySync.update(id, partialItem);
  console.log(updatedItem);
} catch (error) {
  console.error(error);
}

Replace

const id = 121;
const item = {
  date: '2017-08-03T20:45:00.000+01:00',
  homeTeamName: 'Barcelona',
  awayTeamName: 'Paris Saint-Germain',
  homeTeamScore: 6,
  awayTeamScore: 1,
};
try {
  const updatedItem = liveScoreRepositorySync.replace(id, item)
  console.log(updatedItem);
} catch (error) {
  console.error(error);
}

Remove

const id = 121;
try {
  liveScoreRepositorySync.remove(id)
  console.log('removed');
} catch (error) {
  console.error(error);
}

Commands

Run

npm run start

Run development

npm run start/dev

Test

npm run test

Test development

npm run test:watch

| Description | Request method | Request route | Request query params | Request route params | Request body | Response nominal body | Response nominal headers | Response nominal status | Response error body | Response error status | |--------------------------------|----------------|--------------------|--------------------------------------------------------------------------------------------------------------|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------| | Fetch a page of items | GET | /live-scores | pageIndex: natural integer (0, 1, 2, ...)pageSize: positive integer (1, 2, 3, ...) | | | [{ id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 }] | x-total-count: items total count in database: natural integer (0, 1, 2, ...) | 200 | { status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'pageIndex should be a natural integer' }{ status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'pageSize should be a positive integer' } | 400 | | Fetch an item | GET | /live-scores/:id | | id: positive integer (1, 2, 3, ...) | | { id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | | 200 | { status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'id should be a positive integer' }{ status: 404, code: 'RESOURCE_ID_NOT_FOUND', detail: 'no entity found with given id' } | 400404 |
| Create an item | POST | /live-scores | | | { date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | { id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | | 201 | { status: 400, code: 'BAD_RESOURCE_FORMAT', detail: '[attribute] should be a [number/integer/string/ISO date/...]' } | 400 | | Patch an item (partial update) | PATCH | /live-scores/:id | | id: positive integer (1, 2, 3, ...) | { date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | { id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | | 200 | { status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'id should be a positive integer' }{ status: 404, code: 'RESOURCE_ID_NOT_FOUND', detail: 'no entity found with given id' }{ status: 400, code: 'BAD_RESOURCE_FORMAT', detail: '[attribute] should be a [number/integer/string/ISO date/...]' } | 400404 | | Replace an item (full update) | PUT | /live-scores/:id | | id: positive integer (1, 2, 3, ...) | { date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | { id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | | 200 | { status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'id should be a positive integer' }{ status: 404, code: 'RESOURCE_ID_NOT_FOUND', detail: 'no entity found with given id' }{ status: 400, code: 'BAD_RESOURCE_FORMAT', detail: '[attribute] should be a [number/integer/string/ISO date/...]' } | 400404 | | Remove an item | DELETE | /live-scores/:id | | id: positive integer (1, 2, 3, ...) | | { id: 1, date: '2017-08-03T20:45:00.000+01:00', homeTeamName: 'FCB', awayTeamName: 'PSG', homeTeamScore: 6, awayTeamScore: 1 } | | 204 | { status: 400, code: 'BAD_PARAMETER_FORMAT', detail: 'id should be a positive integer' }{ status: 404, code: 'RESOURCE_ID_NOT_FOUND', detail: 'no entity found with given id' } | 400404 |