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

api_httpc

v1.0.6

Published

The HTTPC library is a tool that enables the visual exploration and querying of endpoints in an Express application in a graphical manner. By integrating this library into your project, a /httpc route is added, providing an interactive web interface simil

Downloads

3

Readme

HttpC

HttpC The HTTPC library is a tool that enables the visual exploration and querying of endpoints in an Express application in a graphical manner. By integrating this library into your project, a /api_httpc route is added, providing an interactive web interface similar to Swagger in ASP.NET. Through this interface, developers can directly explore and test the various endpoints of the Express application, including the ability to send parameters and data required for queries. HTTPC simplifies the development process by offering an intuitive and efficient way to interact with the API of the Express application.

Este es un módulo de Node.js.

##install

$ npm install api_httpc $ yarn add api_httpc

api/apimodels/employer - file


export default class Employer {
  constructor(fingerPrint, userCardId, userName, userLastName) {
    super();
    this.fingerPrint = fingerPrint;
    this.userCardId = userCardId;
    this.userName = userName;
    this.userLastName = userLastName;
  }
}

api/routes/employer - file

// In this code, the router class from the 'api_httpc' library is used to define routes in the application.
// The router class is imported from 'api_httpc' and used to create a router in Express.
import express from 'express';
import { router } from 'api_httpc';
import Employer from '../models/employer.js';
import { create, getAll, getById, update, remove, } from '../repositories/employer_repo.js';

// The router class receives an Express object as a parameter in its constructor.
const app = new router(express);

// Allows defining routes with the GET, POST, PUT, and DELETE methods, just like express.

// Some functionalities of the router class:

// - Allows the use of middleware with the use method to perform common actions on all routes.
app.get('/:token',
  (req, res, next) => {
    const token = req.params.token;
    const result = getAll(token);

    if (!result) {
      res.status(401).json({ message: 'Unauthorized' });
      return;
    }

    if (result.error) {
      res.status(500).json({ error: result.error });
      return;
    }

    res.status(200).json(result.data);
  });

// Define routes using the POST method to handle POST requests. In these routes, you can specify an array of strings or the name of a class that identifies the JSON data expected in the request body.
//create employe
app.post(
  '/:token',
  (req, res, next) => {
    const token = req.params.token;
    const body = req.body;

    const result = create(body, token);

    if (!result) {
      res.status(401).json({ message: 'Unauthorized' });
      return;
    }

    if (result.error) {
      res.status(500).json({ error: result.error });
      return;
    }

    res.status(200).json(result);
  },
  Employer
);

/*
* more endpoint
*/

const employed = app.router();
export default employed;

index file


import express from 'express';
import cors from 'cors';
import morgan from 'morgan';
// Help api_httpc create an HTTP client to consume the endpoints created in Express.
import gateway from 'api_httpc';

import Company from './models/company.js';

import company from './routes/company.js';

//----------------------------

import express from 'express';
import cors from 'cors';
import morgan from 'morgan';
import gateway from 'api_httpc';

import Admin from './models/admin.js';

import arrival_registration from './routes/arrival_registration.js';
import employed from './routes/employed.js';
import register from './routes/register.js';

//----------------------------

// The getAttribute class receives an Express object as a parameter in its constructor.
// routes
const gate = new gateway(app);

//settings
app.set('protocol', 'http://');
app.set('domain', 'localhost:');
app.set('port', 8080); //process.env.port

//middlewares
app.use(express.text());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(morgan('dev')); // combined
app.use(
  cors({
    origin: 'http://localhost:3000',
    accept: 'application/json',
    methods: ['GET', 'POST', 'PUT', 'DELETE'],
  })
);

// routes
const gate = new gateway(app);

// - Define routes using the POST method to handle POST requests. In these routes, you can specify an array of strings or the name of a class that identifies the JSON data expected in the request body.
gate.post("/areas", (req, res, next) => {
    const { number1, number2, number3 } = req.body;
    
    const num1 = parseInt(number1);
    const num2 = parseInt(number2);
    const num3 = parseInt(number3);

    setTimeout(function () {
        const result = num1 + (num2 - num3);
        res.status(200).json({ message: "post area", data: result });
    }, 3000);
},["number1","number2","number3"]);

gate.routes('/register', register);
gate.routes('/employed', employed);
gate.routes('/arrival_registration', arrival_registration);

gate.listen(() => console.log(`server on port:${app.get('port')}`));