Skip to content

Commit a2cda3c

Browse files
authored
feat: initial commit (#2)
* feat: initial commit * ci: install prettier * ci: setup git hook for lint-staged * style: formatting * ci: add dependabot config * chore: add generateResetPasswordToken() * chore(package): set node version * ci: remove Github Packages upload * chore(users): remove roles * build: npmignore * build: update eslint, gitignore * build: parcel -> tsc * build: explicit file extensions for imports microsoft/TypeScript#40878 (comment) * chore: add code example * ci: add build step * chore(example): password generation * docs(imports): import-ettiquette * docs(type): `JSDocs` for QueryParameter types
1 parent 9966911 commit a2cda3c

30 files changed

+11707
-74
lines changed

.eslintignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Node modules
2+
node_modules
3+
4+
# Build, examples
5+
dist
6+
examples
7+
8+
# Config
9+
.eslintrc.cjs
10+
commitlint.config.cjs

.eslintrc.cjs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
env: {
3+
es2021: true,
4+
node: true,
5+
commonjs: true,
6+
},
7+
extends: [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
11+
"prettier",
12+
],
13+
plugins: ["@typescript-eslint"],
14+
parser: "@typescript-eslint/parser",
15+
overrides: [],
16+
parserOptions: {
17+
ecmaVersion: "latest",
18+
sourceType: "module",
19+
project: "./tsconfig.json",
20+
},
21+
rules: {
22+
"valid-jsdoc": 1,
23+
"require-jsdoc": 1,
24+
"@typescript-eslint/no-explicit-any": 0,
25+
},
26+
};

.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
# Look for `package.json` and `lock` files in the `root` directory
6+
directory: "/"
7+
schedule:
8+
interval: "monthly"
9+
reviewers:
10+
- "adnan-kamili"
11+
target-branch: "develop"
12+
commit-message:
13+
prefix: "ci(dependabot)"
14+
include: "scope"
15+
ignore:
16+
- dependency-name: "prettier"

.github/workflows/release.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# Release Please creates a PR on main
11+
- uses: google-github-actions/release-please-action@v3
12+
id: release
13+
with:
14+
release-type: node
15+
package-name: test-release-please
16+
17+
# Publish to NPM
18+
- uses: actions/checkout@v3
19+
# If statements ensure that release is published to registries only when a new release is created.
20+
if: ${{ steps.release.outputs.release_created }}
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: 16
24+
registry-url: "https://registry.npmjs.org"
25+
if: ${{ steps.release.outputs.release_created }}
26+
- run: npm ci
27+
- run: npm run build
28+
if: ${{ steps.release.outputs.release_created }}
29+
- run: npm publish
30+
env:
31+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
32+
if: ${{ steps.release.outputs.release_created }}

.gitignore

+1-73
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,10 @@ pids
1515
*.seed
1616
*.pid.lock
1717

18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
26-
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
37-
# Compiled binary addons (https://nodejs.org/api/addons.html)
38-
build/Release
39-
4018
# Dependency directories
4119
node_modules/
4220
jspm_packages/
4321

44-
# TypeScript v1 declaration files
45-
typings/
46-
4722
# TypeScript cache
4823
*.tsbuildinfo
4924

@@ -53,52 +28,5 @@ typings/
5328
# Optional eslint cache
5429
.eslintcache
5530

56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
68-
# Yarn Integrity file
69-
.yarn-integrity
70-
71-
# dotenv environment variables file
72-
.env
73-
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
31+
# Build files
8332
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
102-
103-
# TernJS port file
104-
.tern-port

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no -- commitlint --edit ${1}

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.npmignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Source files, examples
2+
src
3+
examples
4+
5+
# Linting/Formatting Configs
6+
.eslintrc.cjs
7+
.eslintignore
8+
.prettierignore
9+
.prettierrc.json
10+
commitlint.config.cjs
11+
lint-staged.config.cjs
12+
13+
# Husky Git Hooks
14+
.husky
15+
16+
# Github Workflows
17+
.github

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.parcel-cache

.prettierrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"quoteProps": "consistent"
3+
}

CHANGELOG.md

Whitespace-only changes.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# web-api-client
1+
# web-api-client

commitlint.config.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ["@commitlint/config-conventional"] };

examples/index.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
CryptlexWebApiClient,
3+
CryptlexWebApiClientOptions,
4+
} from "@cryptlex/web-api-client";
5+
import { nanoid } from "nanoid";
6+
7+
const ACCESS_TOKEN = "**ACCESS_TOKEN**";
8+
const PRODUCT_ID = "**PRODUCT_ID**";
9+
10+
const cryptlexWebApiClientOptions = new CryptlexWebApiClientOptions(
11+
ACCESS_TOKEN
12+
);
13+
const cryptlexWebApiClient = new CryptlexWebApiClient(
14+
cryptlexWebApiClientOptions
15+
);
16+
17+
main();
18+
19+
/**
20+
* This function creates a User and then subsequently creates a license linked to that user.
21+
*/
22+
async function main() {
23+
try {
24+
const userResponse = await cryptlexWebApiClient.createUser({
25+
26+
firstName: "John",
27+
lastName: "Doe",
28+
password: nanoid(),
29+
role: "user",
30+
});
31+
console.log(
32+
"\nSuccessfully created user: " + JSON.stringify(userResponse.data)
33+
);
34+
35+
// Create a license which is linked to the new user in the product defined by PRODUCT_ID
36+
const licenseResponse = await cryptlexWebApiClient.createLicense({
37+
productId: PRODUCT_ID,
38+
userId: userResponse.data.id,
39+
});
40+
console.log(
41+
"\nSuccessfully created license: " + JSON.stringify(licenseResponse.data)
42+
);
43+
} catch (error) {
44+
console.error(error);
45+
}
46+
}

examples/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@cryptlex/web-api-client-example",
3+
"version": "1.0.0",
4+
"type": "module",
5+
"description": "An example to show the working of the Cryptlex Web API client",
6+
"main": "index.js",
7+
"scripts": {
8+
"start": "node index.js",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"author": "Cryptlex LLC",
12+
"license": "ISC",
13+
"dependencies": {
14+
"@cryptlex/web-api-client": "latest",
15+
"nanoid": "^4.0.0"
16+
}
17+
}

lint-staged.config.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
"*.ts": "eslint --fix",
3+
"*.{cjs,mjs,js,ts,html,scss,css,json,md}": "prettier --write",
4+
};

0 commit comments

Comments
 (0)