Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial commit (#2) #4

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Node modules
node_modules

# Build, examples
dist
examples

# Config
.eslintrc.cjs
commitlint.config.cjs
26 changes: 26 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
env: {
es2021: true,
node: true,
commonjs: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
],
plugins: ["@typescript-eslint"],
parser: "@typescript-eslint/parser",
overrides: [],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
},
rules: {
"valid-jsdoc": 1,
"require-jsdoc": 1,
"@typescript-eslint/no-explicit-any": 0,
},
};
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "adnan-kamili"
target-branch: "develop"
commit-message:
prefix: "ci(dependabot)"
include: "scope"
ignore:
- dependency-name: "prettier"
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# Release Please creates a PR on main
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: test-release-please

# Publish to NPM
- uses: actions/checkout@v3
# If statements ensure that release is published to registries only when a new release is created.
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}
- run: npm ci
- run: npm run build
if: ${{ steps.release.outputs.release_created }}
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
74 changes: 1 addition & 73 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,10 @@ pids
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

Expand All @@ -53,52 +28,5 @@ typings/
# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
# Build files
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
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"

npx --no -- 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"

npx lint-staged
17 changes: 17 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Source files, examples
src
examples

# Linting/Formatting Configs
.eslintrc.cjs
.eslintignore
.prettierignore
.prettierrc.json
commitlint.config.cjs
lint-staged.config.cjs

# Husky Git Hooks
.husky

# Github Workflows
.github
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.parcel-cache
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"quoteProps": "consistent"
}
Empty file added CHANGELOG.md
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# web-api-client
# web-api-client
1 change: 1 addition & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
46 changes: 46 additions & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
CryptlexWebApiClient,
CryptlexWebApiClientOptions,
} from "@cryptlex/web-api-client";
import { nanoid } from "nanoid";

const ACCESS_TOKEN = "**ACCESS_TOKEN**";
const PRODUCT_ID = "**PRODUCT_ID**";

const cryptlexWebApiClientOptions = new CryptlexWebApiClientOptions(
ACCESS_TOKEN
);
const cryptlexWebApiClient = new CryptlexWebApiClient(
cryptlexWebApiClientOptions
);

main();

/**
* This function creates a User and then subsequently creates a license linked to that user.
*/
async function main() {
try {
const userResponse = await cryptlexWebApiClient.createUser({
email: "john@doe.com",
firstName: "John",
lastName: "Doe",
password: nanoid(),
role: "user",
});
console.log(
"\nSuccessfully created user: " + JSON.stringify(userResponse.data)
);

// Create a license which is linked to the new user in the product defined by PRODUCT_ID
const licenseResponse = await cryptlexWebApiClient.createLicense({
productId: PRODUCT_ID,
userId: userResponse.data.id,
});
console.log(
"\nSuccessfully created license: " + JSON.stringify(licenseResponse.data)
);
} catch (error) {
console.error(error);
}
}
17 changes: 17 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@cryptlex/web-api-client-example",
"version": "1.0.0",
"type": "module",
"description": "An example to show the working of the Cryptlex Web API client",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Cryptlex LLC",
"license": "ISC",
"dependencies": {
"@cryptlex/web-api-client": "latest",
"nanoid": "^4.0.0"
}
}
4 changes: 4 additions & 0 deletions lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
"*.ts": "eslint --fix",
"*.{cjs,mjs,js,ts,html,scss,css,json,md}": "prettier --write",
};
Loading