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

@eienjs/dev-tools

v1.0.0

Published

Tools for develop fast and easy adonis apps

Downloads

69

Readme

@eienjs/dev-tools

Tools for develop fast and easy adonis apps

Installation

Install and configure the package using the following command :

node ace add @eienjs/dev-tools

Usage

This library exports helper utility ResponseStatusText corresponding text given a ResponseStatus code. For example:

import { ResponseStatus } from '@adonisjs/core/http';
import { ResponseStatusText } from '@eienjs/dev-tools';

const statusAcceptedText = ResponseStatusText[ResponseStatus.Accepted];
console.info(statusAcceptedText); // Accepted

Japa Api Client Helpers

For testing add methods on assert client responses like a check status with corresponding ResponseStatus

import { test } from '@japa/runner';

test.group('Users list', () => {
  test('get a list of users', async ({ client }) => {
    const response = await client.get('/users');

    // Next is equivalent to response.assertStatus(200);
    response.assertOk();

    response.assertBody({
      data: [
        {
          id: 1,
          email: '[email protected]',
        },
      ],
    });
  });
});

Added assertMethods corresponding to ResponseStatus:

/**
 * Assert response status to match the expected status 100
 */
assertContinue(): void;
/**
 * Assert response status to match the expected status 101
 */
assertSwitchingProtocols(): void;
/**
 * Assert response status to match the expected status 102
 */
assertProcessing(): void;
/**
 * Assert response status to match the expected status 103
 */
assertEarlyHints(): void;
/**
 * Assert response status to match the expected status 200
 */
assertOk(): void;
/**
 * Assert response status to match the expected status 201
 */
assertCreated(): void;
/**
 * Assert response status to match the expected status 202
 */
assertAccepted(): void;
/**
 * Assert response status to match the expected status 203
 */
assertNonAuthoritativeInformation(): void;
/**
 * Assert response status to match the expected status 204
 */
assertNoContent(): void;
/**
 * Assert response status to match the expected status 205
 */
assertResetContent(): void;
/**
 * Assert response status to match the expected status 206
 */
assertPartialContent(): void;
/**
 * Assert response status to match the expected status 207
 */
assertMultiStatus(): void;
/**
 * Assert response status to match the expected status 208
 */
assertAlreadyReported(): void;
/**
 * Assert response status to match the expected status 226
 */
assertIMUsed(): void;
/**
 * Assert response status to match the expected status 300
 */
assertMultipleChoices(): void;
/**
 * Assert response status to match the expected status 301
 */
assertMovedPermanently(): void;
/**
 * Assert response status to match the expected status 302
 */
assertFound(): void;
/**
 * Assert response status to match the expected status 303
 */
assertSeeOther(): void;
/**
 * Assert response status to match the expected status 304
 */
assertNotModified(): void;
/**
 * Assert response status to match the expected status 305
 */
assertUseProxy(): void;
/**
 * Assert response status to match the expected status 307
 */
assertTemporaryRedirect(): void;
/**
 * Assert response status to match the expected status 308
 */
assertPermanentRedirect(): void;
/**
 * Assert response status to match the expected status 400
 */
assertBadRequest(): void;
/**
 * Assert response status to match the expected status 401
 */
assertUnauthorized(): void;
/**
 * Assert response status to match the expected status 402
 */
assertPaymentRequired(): void;
/**
 * Assert response status to match the expected status 403
 */
assertForbidden(): void;
/**
 * Assert response status to match the expected status 404
 */
assertNotFound(): void;
/**
 * Assert response status to match the expected status 405
 */
assertMethodNotAllowed(): void;
/**
 * Assert response status to match the expected status 406
 */
assertNotAcceptable(): void;
/**
 * Assert response status to match the expected status 407
 */
assertProxyAuthenticationRequired(): void;
/**
 * Assert response status to match the expected status 408
 */
assertRequestTimeout(): void;
/**
 * Assert response status to match the expected status 409
 */
assertConflict(): void;
/**
 * Assert response status to match the expected status 410
 */
assertGone(): void;
/**
 * Assert response status to match the expected status 411
 */
assertLengthRequired(): void;
/**
 * Assert response status to match the expected status 412
 */
assertPreconditionFailed(): void;
/**
 * Assert response status to match the expected status 413
 */
assertPayloadTooLarge(): void;
/**
 * Assert response status to match the expected status 414
 */
assertURITooLong(): void;
/**
 * Assert response status to match the expected status 415
 */
assertUnsupportedMediaType(): void;
/**
 * Assert response status to match the expected status 416
 */
assertRangeNotSatisfiable(): void;
/**
 * Assert response status to match the expected status 417
 */
assertExpectationFailed(): void;
/**
 * Assert response status to match the expected status 418
 */
assertImATeapot(): void;
/**
 * Assert response status to match the expected status 421
 */
assertMisdirectedRequest(): void;
/**
 * Assert response status to match the expected status 422
 */
assertUnprocessableEntity(): void;
/**
 * Assert response status to match the expected status 423
 */
assertLocked(): void;
/**
 * Assert response status to match the expected status 424
 */
assertFailedDependency(): void;
/**
 * Assert response status to match the expected status 425
 */
assertTooEarly(): void;
/**
 * Assert response status to match the expected status 426
 */
assertUpgradeRequired(): void;
/**
 * Assert response status to match the expected status 428
 */
assertPreconditionRequired(): void;
/**
 * Assert response status to match the expected status 429
 */
assertTooManyRequests(): void;
/**
 * Assert response status to match the expected status 431
 */
assertRequestHeaderFieldsTooLarge(): void;
/**
 * Assert response status to match the expected status 451
 */
assertUnavailableForLegalReasons(): void;
/**
 * Assert response status to match the expected status 500
 */
assertInternalServerError(): void;
/**
 * Assert response status to match the expected status 501
 */
assertNotImplemented(): void;
/**
 * Assert response status to match the expected status 502
 */
assertBadGateway(): void;
/**
 * Assert response status to match the expected status 503
 */
assertServiceUnavailable(): void;
/**
 * Assert response status to match the expected status 504
 */
assertGatewayTimeout(): void;
/**
 * Assert response status to match the expected status 505
 */
assertHTTPVersionNotSupported(): void;
/**
 * Assert response status to match the expected status 506
 */
assertVariantAlsoNegotiates(): void;
/**
 * Assert response status to match the expected status 507
 */
assertInsufficientStorage(): void;
/**
 * Assert response status to match the expected status 508
 */
assertLoopDetected(): void;
/**
 * Assert response status to match the expected status 510
 */
assertNotExtended(): void;
/**
 * Assert response status to match the expected status 511
 */
assertNetworkAuthenticationRequired(): void;

Response Helpers

Added three methods for follow standard jsend more information on https://github.com/omniti-labs/jsend for api responses.

Small example of usage

import { type HttpContext } from '@adonisjs/core/http';
import User from '#models/user';
import { loginValidator } from '#validators/auth/login';

export default class LoginController {
  public async handle({ request, response, auth }: HttpContext): Promise<void> {
    const { email, password } = await request.validateUsing(loginValidator);
    const user = await User.verifyCredentials(email, password);
    await auth.use('web').login(user);

    response.jsendSuccess({ auth: 'Sesión iniciada' });
  }
}

Methods:

/**
 * Send success response using jsend standard
 *
 */
jsendSuccess(result: unknown, httpCode?: number): void;

/**
 * Send fail response using jsend standard
 *
 */
jsendFail(errors: Record<string, unknown>, httpCode?: number): void;

/**
 * Send error response using jsend standard
 *
 */
jsendError(
  message: string,
  options?: { httpCode?: number; code?: string | number; errors?: unknown },
): void;

Request Helpers

Method helper on request wantsJSON() check if current request includes json accept header.