From a0e91b508b09140f25dac7470d5e5eaed07ef433 Mon Sep 17 00:00:00 2001 From: Jey Date: Sat, 13 Jul 2024 13:48:08 -0300 Subject: [PATCH] configuration to use require for module import --- README.md | 2 +- cypress.config.js | 4 ++-- cypress/e2e/fakeBankAccount.cy.js | 4 +--- httpcodes.js | 4 +++- index.mjs => index.js | 14 +++++++++----- package.json | 3 +-- 6 files changed, 17 insertions(+), 14 deletions(-) rename index.mjs => index.js (90%) diff --git a/README.md b/README.md index 08b6903..134c640 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ npm install --save-dev fakerbankbr ## 🪄Uso ```javascript -import { createFakeBankAccount } from 'fakerbankbr'; +const { createFakeBankAccount } = require('fakerbankbr'); // Gerar uma única conta bancária let conta; diff --git a/cypress.config.js b/cypress.config.js index 17161e3..5b7f546 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,6 +1,6 @@ -import { defineConfig } from "cypress"; +const { defineConfig } = require('cypress'); -export default defineConfig({ +module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { // implement node event listeners here diff --git a/cypress/e2e/fakeBankAccount.cy.js b/cypress/e2e/fakeBankAccount.cy.js index 7311be6..9f92d2d 100644 --- a/cypress/e2e/fakeBankAccount.cy.js +++ b/cypress/e2e/fakeBankAccount.cy.js @@ -1,6 +1,4 @@ -// cypress/integration/fakeBankAccount.spec.js - -import { createFakeBankAccount } from '../../index.mjs'; +const { createFakeBankAccount } = require('../../index'); describe('createFakeBankAccount', () => { it('should create a single fake bank account', () => { diff --git a/httpcodes.js b/httpcodes.js index 86d9d7e..4122bbc 100644 --- a/httpcodes.js +++ b/httpcodes.js @@ -1,4 +1,4 @@ -export default { +const httpcodes = { 0: { code: 'Not Error', why: 'Default message to default response from code.', @@ -260,3 +260,5 @@ export default { why: 'This code means that the user needs to authenticate himself to have access to some network.', }, }; + +module.exports = httpcodes; diff --git a/index.mjs b/index.js similarity index 90% rename from index.mjs rename to index.js index 525907e..48d8486 100644 --- a/index.mjs +++ b/index.js @@ -1,10 +1,10 @@ 'use strict'; -import cheerio from 'cheerio'; -import https from 'https'; -import querystring from 'querystring'; -import httpcodes from './httpcodes.js'; +const cheerio = require('cheerio'); +const httpcodes = require('./httpcodes'); // Assumindo que httpcodes.js está no mesmo diretório +const https = require('https'); +const querystring = require('querystring'); -export const createFakeBankAccount = (quantity = 1) => { +const createFakeBankAccount = (quantity = 1) => { return new Promise((resolve, reject) => { if (quantity > 10) { quantity = 10; @@ -135,3 +135,7 @@ function parseResponse(res, data) { return response; } + +module.exports = { + createFakeBankAccount: createFakeBankAccount, +}; diff --git a/package.json b/package.json index d50bb2f..79782d0 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ { "name": "fakerbankbr", - "version": "1.1.0", + "version": "1.1.1", "description": "O fakerBankBR é um wrapper em Node.js para o serviço 4devs que permite gerar dados bancários falsos brasileiros. Este pacote é uma simples de obter informações de contas bancárias fictícias, incluindo número da conta, dígito verificador, agência e banco. É útil para testes de software, desenvolvimento e qualquer outro cenário em que dados bancários válidos sejam necessários sem comprometer a segurança.", "main": "index.js", - "type": "module", "scripts": { "test": "npx cypress open", "test:headless": "npx cypress run"