Skip to content

Commit d03b5f2

Browse files
committed
πŸŽ‰ kick off the project
kick off the project πŸŽ‰ Initial commit
0 parents  commit d03b5f2

19 files changed

+8542
-0
lines changed

β€Ž.env.template

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://github.com/settings/tokens?type=beta with the gist read/write permissions
2+
GITHUB_TOKEN=""
3+
# Must be 256 bits (32 characters)
4+
ENCRYPTION_KEY=""

β€Ž.eslintrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"es2021": true,
4+
"node": true,
5+
"jest": true
6+
},
7+
"extends": ["standard", "plugin:typescript-sort-keys/recommended"],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": 13,
11+
"sourceType": "module"
12+
},
13+
"plugins": ["@typescript-eslint"],
14+
"rules": {
15+
"indent": "off",
16+
"space-before-function-paren": "off",
17+
"no-unused-vars": "warn"
18+
}
19+
}

β€Ž.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ko_fi: linesofcodedev
2+
custom: ['https://www.paypal.me/TimMikeladze']

β€Ž.github/workflows/main.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Main CI workflow
2+
3+
on: [push]
4+
5+
jobs:
6+
run-ci:
7+
name: Run Type Check & Linters
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 10
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up Node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
22+
- name: Install dependencies (with cache)
23+
uses: bahmutov/npm-install@v1
24+
25+
- name: Check types
26+
run: yarn type-check
27+
28+
- name: Check linting
29+
run: yarn lint
30+
31+
- name: Test
32+
run: yarn test:ci
33+
34+
- name: Build
35+
run: yarn build

β€Ž.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.idea
4+
yarn-error.log
5+
coverage
6+
.env

β€Ž.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint-staged

β€Ž.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact = true

β€Ž.prettierignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dist
2+
coverage
3+
*.lock
4+
*.snap
5+
.prettierignore
6+
.env.template
7+
.gitignore
8+
.husky/**
9+
.npmrc

β€Ž.prettierrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none"
5+
}

β€ŽLICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Tim Mikeladze
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

β€Ž__tests__/GistDatabase.test.ts

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { get, set, GistDatabase, del } from '../src'
2+
3+
describe('GistDatabase', () => {
4+
let db: GistDatabase
5+
beforeAll(() => {
6+
db = new GistDatabase({
7+
token: process.env.GITHUB_TOKEN
8+
})
9+
})
10+
afterAll(async () => {
11+
await db.destroy()
12+
})
13+
it('initializes', async () => {
14+
expect(await db.init()).toMatchObject({
15+
id: expect.any(String)
16+
})
17+
expect(db).toBeDefined()
18+
})
19+
it('sets and gets', async () => {
20+
const res = await db.set('test_one', {
21+
name: 'test_one'
22+
})
23+
expect(res).toMatchObject({
24+
value: {
25+
name: 'test_one'
26+
},
27+
id: expect.any(String),
28+
gist: expect.any(Object)
29+
})
30+
expect(await db.get('test_one')).toEqual({
31+
value: {
32+
name: 'test_one'
33+
},
34+
id: expect.any(String),
35+
gist: expect.any(Object)
36+
})
37+
})
38+
it('deletes', async () => {
39+
await db.set('test_two', {
40+
name: 'test_two'
41+
})
42+
expect(await db.get('test_two')).toEqual({
43+
value: {
44+
name: 'test_two'
45+
},
46+
id: expect.any(String),
47+
gist: expect.any(Object)
48+
})
49+
await db.delete('test_two')
50+
expect(await db.get('test_two')).toBeUndefined()
51+
})
52+
})
53+
54+
it('get and set and del', () => {
55+
const obj = {
56+
a: 1,
57+
b: {
58+
c: {}
59+
}
60+
}
61+
expect(get(obj, ['a'])).toBe(1)
62+
expect(get(obj, ['b', 'c'])).toEqual({})
63+
64+
let res = set(obj, ['a'], 2)
65+
expect(get(res, ['a'])).toBe(2)
66+
res = set(res, ['b', 'c'], { d: 3 })
67+
expect(get(res, ['b', 'c'])).toEqual({ d: 3 })
68+
69+
res = del(res, ['b', 'c'])
70+
71+
expect(get(res, ['b', 'c'])).toBeUndefined()
72+
expect(get(res, ['a'])).toBe(2)
73+
})

β€Žcommit.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { GitEmoji } from 'commit-it'
2+
3+
export default {
4+
plugins: [
5+
new GitEmoji({
6+
askForShortDescription: false,
7+
commitBodyRequired: false
8+
})
9+
]
10+
}

β€Žjest.config.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"preset": "ts-jest/presets/default-esm",
3+
"testEnvironment": "node",
4+
"testPathIgnorePatterns": ["<rootDir>/node_modules/"],
5+
"setupFiles": ["dotenv/config"],
6+
"testMatch": ["**/?(*.)+(spec|test).[jt]s?(x)"],
7+
"transform": {
8+
"^.+\\.tsx?$": [
9+
"ts-jest",
10+
{
11+
"isolatedModules": true,
12+
"useESM": true
13+
}
14+
]
15+
}
16+
}

β€Žpackage.json

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"name": "gist-database",
3+
"version": "0.0.0",
4+
"description": "",
5+
"author": "Tim Mikeladze <[email protected]>",
6+
"keywords": [],
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/TimMikeladze/gist-database.git"
10+
},
11+
"license": "MIT",
12+
"files": [
13+
"./dist"
14+
],
15+
"source": "src/index.ts",
16+
"types": "dist/index.d.ts",
17+
"type": "module",
18+
"exports": {
19+
"require": "./dist/index.cjs",
20+
"default": "./dist/index.modern.js"
21+
},
22+
"main": "./dist/index.cjs",
23+
"module": "./dist/index.module.js",
24+
"unpkg": "./dist/index.umd.js",
25+
"scripts": {
26+
"dev": "microbundle watch src/{index}.ts --target node -f modern",
27+
"build": "rm -rf dist && microbundle src/{index}.ts",
28+
"lint": "eslint --fix \"{src,__tests__}/**/*.+(ts|tsx|js|jsx)\" && prettier --write .",
29+
"test": "yarn node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
30+
"test:ci": "yarn test --ci --coverage",
31+
"prepublishOnly": "yarn type-check && yarn lint && yarn test && yarn build",
32+
"type-check": "tsc",
33+
"release": "release-it",
34+
"commit": "commit-it"
35+
},
36+
"release-it": {
37+
"git": {
38+
"commitMessage": "πŸ”– | v${version}"
39+
},
40+
"github": {
41+
"release": true
42+
},
43+
"npm": {
44+
"publish": false
45+
}
46+
},
47+
"lint-staged": {
48+
"**/*.{ts,js,jsx,tsx}": "eslint --fix",
49+
"*": "prettier --write"
50+
},
51+
"husky": {
52+
"hooks": {
53+
"pre-commit": "lint-staged"
54+
}
55+
},
56+
"devDependencies": {
57+
"@types/jest": "29.2.4",
58+
"@types/node": "18.11.13",
59+
"@types/object-hash": "3.0.2",
60+
"@typescript-eslint/eslint-plugin": "5.46.1",
61+
"@typescript-eslint/parser": "5.46.1",
62+
"commit-it": "0.0.7",
63+
"dotenv": "16.0.3",
64+
"eslint": "8.29.0",
65+
"eslint-config-standard": "17.0.0",
66+
"eslint-plugin-import": "2.26.0",
67+
"eslint-plugin-n": "15.6.0",
68+
"eslint-plugin-node": "11.1.0",
69+
"eslint-plugin-promise": "6.1.1",
70+
"eslint-plugin-typescript-sort-keys": "2.1.0",
71+
"husky": "8.0.2",
72+
"jest": "29.3.1",
73+
"lint-staged": "13.1.0",
74+
"microbundle": "0.15.1",
75+
"prettier": "2.8.1",
76+
"release-it": "15.5.1",
77+
"ts-jest": "29.0.3",
78+
"typescript": "4.9.4"
79+
},
80+
"dependencies": {
81+
"crypto": "1.0.1",
82+
"is-plain-obj": "4.1.0",
83+
"node-fetch": "3.3.0",
84+
"zod": "3.20.2"
85+
},
86+
"resolutions": {}
87+
}

β€Žrenovate.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": ["config:base"],
3+
"stabilityDays": 3,
4+
"timezone": "America/Los_Angeles",
5+
"schedule": ["on the first day of the month"],
6+
"packageRules": [
7+
{
8+
"matchPackagePatterns": ["*"],
9+
"matchUpdateTypes": ["minor", "patch"],
10+
"groupName": "all non-major dependencies",
11+
"groupSlug": "all-minor-patch"
12+
}
13+
],
14+
"ignoreDeps": []
15+
}

0 commit comments

Comments
Β (0)