Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
trs committed Aug 25, 2023
0 parents commit 7b62b45
Show file tree
Hide file tree
Showing 67 changed files with 13,486 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
env: {
node: true,
es2021: true,
jest: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
overrides: [],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint", "prettier"],
rules: {
"prettier/prettier": "error",
},
ignorePatterns: ["build", "node_modules", ".husky", ".yarn"],
};
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish

on:
push:
branches: [main]

jobs:
test:
uses: ./.github/workflows/test.yml

release:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
cache: "yarn"
- name: Install
run: yarn install --immutable
- name: Build
run: yarn build
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on:
pull_request:
branches: [main]
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install
run: yarn install --immutable
- name: Lint
run: yarn lint:check
- name: Test
run: yarn test
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
build
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
23 changes: 23 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"target": "es2021",
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"]
}
},
"module": {
"type": "commonjs",
"strict": true
},
"sourceMaps": true
}
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "test",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "yarn",
"runtimeArgs": ["test", "--verbose", "--watch", "--onlyChanged"],
"sourceMaps": true,
"pauseForSourceMap": true,
"smartStep": true,
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "test:file",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "yarn",
"runtimeArgs": [
"test",
"${relativeFile}",
"--verbose",
"--watchAll",
"--runInBand"
],
"sourceMaps": true,
"pauseForSourceMap": true,
"smartStep": true,
"console": "integratedTerminal"
}
]
}
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-3.4.1.cjs
nodeLinker: node-modules
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# NestJS Chargebee
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
transform: {
"^.+\\.(t|j)s?$": ["@swc/jest", { sourceMaps: "inline" }],
},
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
modulePathIgnorePatterns: ["<rootDir>/build/"],
testMatch: ["<rootDir>/src/**/*.test.ts"],
testEnvironment: "node",
collectCoverage: false,
};
88 changes: 88 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"name": "nestjs-chargebee",
"version": "0.1.0",
"exports": {
".": {
"types": "./build/types/main.d.ts",
"import": "./build/esm/main.js",
"default": "./build/cjs/main.js"
}
},
"main": "build/cjs/main.js",
"types": "build/types/main.d.ts",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/voiceflow/nestjs-chargebee.git"
},
"scripts": {
"postinstall": "husky install",
"prepack": "pinst --disable",
"postpack": "pinst --enable",
"build": "yarn run-p build:cjs build:esm build:types",
"prebuild:cjs": "yarn rimraf build/cjs",
"build:cjs": "yarn prebuild:cjs && yarn swc src -d build/cjs --config module.type=commonjs && yarn postbuild:cjs",
"postbuild:cjs": "touch build/cjs/package.json && echo '{ \"type\": \"commonjs\" }' > build/cjs/package.json",
"prebuild:esm": "yarn rimraf build/esm",
"build:esm": "yarn prebuild:esm && yarn swc src -d build/esm --config module.type=es6 && yarn postbuild:esm",
"postbuild:esm": "touch build/esm/package.json && echo '{ \"type\": \"module\" }' > build/esm/package.json",
"build:types": "yarn tsc -p tsconfig.build.json",
"test": "yarn jest --passWithNoTests",
"lint": "yarn eslint --fix src",
"lint:check": "yarn eslint src"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"*.{ts,js}": "yarn eslint --fix",
"*.{md,json,yml}": "yarn prettier --write"
},
"release": {
"branches": [
"main"
]
},
"dependencies": {
"chargebee-typescript": "2.23.0"
},
"devDependencies": {
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@nestjs/common": "^10.1.3",
"@nestjs/core": "^10.1.3",
"@nestjs/testing": "^10.1.3",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.72",
"@swc/jest": "^0.2.27",
"@types/jest": "^29.5.3",
"@types/q": "^1.5.5",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"jest": "^29.6.2",
"lint-staged": "^13.2.3",
"npm-run-all": "^4.1.5",
"pinst": "^3.0.0",
"prettier": "^3.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.1",
"rxjs": "^7.8.1",
"semantic-release": "^21.0.7",
"supertest": "^6.3.3",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"typescript": "^5.1.6"
},
"peerDependencies": {
"@nestjs/common": "^9 || ^10",
"rxjs": "^7"
},
"packageManager": "yarn@3.4.1"
}
24 changes: 24 additions & 0 deletions src/chargebee-client.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Inject, Injectable, Optional } from "@nestjs/common";
import { ChargeBee } from "chargebee-typescript";

import { ChargebeeModuleOptions } from "./chargebee.interface";
import { CHARGEBEE_MODULE_OPTIONS_TOKEN } from "./chargebee.module-definition";

@Injectable()
export class ChargebeeClientService {
constructor(
@Inject(CHARGEBEE_MODULE_OPTIONS_TOKEN)
options: ChargebeeModuleOptions,
@Optional()
private _client = new ChargeBee(),
) {
this._client.configure({
site: options.site,
api_key: options.apiKey,
});
}

public get client(): ChargeBee {
return this._client;
}
}
Loading

0 comments on commit 7b62b45

Please sign in to comment.