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

alterna-contract-api

v2.0.1

Published

API for Alterna's contracts information.

Downloads

1

Readme

nodejs-boilerplate

This is a repository boilerplate for creating a NodeJS Alterna API. Currently is using git instead of npm as registry. It gives you a template with basic folder structure and test/eslit dependencies ready.

Using the boilerplate

These are the steps you need to follow for using this boilerplate:

  1. Create your new repository
  2. Clone this repository
  3. Move to this repository and run these commands:
    1. rm -rf .git
    2. git init
    3. git remote add origin [email protected]:flipenergia/your-new-and-fresh-repo.git
    4. git pull origin master
    5. git add .
    6. git commit -m "initial commit"
    7. git push -ff --set-upstream origin master

Once you have done these steps you can also rename the name of the directory containing the new repository: mv nodejs-boilerplate-api your-new-and-fresh-repo. Also is a good idea to update the package.json with all the properties related to the repository and the package as:

  • name
  • version (start with 0.0.1 is useful for prototyping)
  • description
  • repository.url
  • author
  • homepage

Deploying a version

Once you want to deploy a version you need to:

  • Commit all your changes
  • Increase the package version at package.json following semantic versioning
  • Commit this change with the version prefixed with v as commit message. For version 1.0.0: git commit -m "v1.0.0"
  • Run npm run tag at the root of the project.

Using the library

Let's say you are going to use the package [email protected] in one of your projects. You need to copy the repository url for being imported through ssh and also being sure that the machine where you are going to import it has also the ssh key enabled in alterna-log repository.

Once you have all that sorted out you just need to run:

# You can also install it as dev dependency with npm install -D
npm install "git+ssh://[email protected]/flipenergia/alterna-log.git#v1.0.0"

The next time you deploy a new version for the library you just need to update the dependency version in the package.json and run npm run update alterna-log.

Scripts

  • lint: Executes the linter for the project following the config using ESlint.
  • tag: Generates automatically the tag for git based on package.json version and pull everything to remote.
  • test: Run the build script and then execute tests with Mocha and Chai.

Installation

fastify

  npm i fastify --save

fastify-env plugin

  • Which helps you with loading environment variables and setting defaults for each variable

    npm install --save fastify-env

Instructions

Execute the next command:

  node index.js

Output:

  Registered route: /
  Registered route: /api/blogs
  Registered route: /api/blogs/:id

  {:30,"time":1620383671607,"pid":20155,"hostname":"artemisa","msg":"Server listening at http://127.0.0.1:40235"}
  {"level":30,"time":1620383671608,"pid":20155,"hostname":"artemisa","msg":"Server listening on http://127.0.0.1:40235"}

Test the following calls in the browser (look at the port that has been opened on the server):

  • http://localhost:40235
  • http://localhost:40235/api/blogs
  • http://localhost:40235/api/blogs/1
  • http://localhost:40235/api/blogs/2
  • http://localhost:40235/api/blogs/3

TO DO

  • Add integration with documentación of swagger
  • It always set the same port
  • Testing post, put, delete methods
  • Include mocha or jest tests to validate defined methods