Skip to content

Commit 740b1ef

Browse files
committed
feat: Initial public commit
0 parents  commit 740b1ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+15231
-0
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/benchmark
2+
/cjs
3+
/docs
4+
/esm
5+
/tmp

.eslintrc.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"standard",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
7+
"prettier"
8+
],
9+
"overrides": [
10+
{
11+
"files": ["**.test.ts"],
12+
"rules": {
13+
"@typescript-eslint/no-unsafe-member-access": "off",
14+
"@typescript-eslint/no-unused-expressions": "off",
15+
"@typescript-eslint/no-unsafe-assignment": "off",
16+
"@typescript-eslint/unbound-method": "off",
17+
"no-unused-expressions": "off"
18+
}
19+
}
20+
],
21+
"parser": "@typescript-eslint/parser",
22+
"parserOptions": {
23+
"project": ["./tsconfig.json"],
24+
"sourceType": "module",
25+
"tsconfigRootDir": "."
26+
},
27+
"rules": {
28+
"@typescript-eslint/array-type": ["error", { "default": "array" }],
29+
"@typescript-eslint/ban-ts-comment": [
30+
"error",
31+
{
32+
"minimumDescriptionLength": 5,
33+
"ts-expect-error": "allow-with-description",
34+
"ts-ignore": true,
35+
"ts-nocheck": false,
36+
"ts-check": true
37+
}
38+
],
39+
"@typescript-eslint/ban-types": "warn",
40+
"@typescript-eslint/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
41+
"@typescript-eslint/consistent-type-assertions": ["warn", { "assertionStyle": "as" }],
42+
"@typescript-eslint/explicit-function-return-type": [
43+
"warn",
44+
{
45+
"allowExpressions": true,
46+
"allowTypedFunctionExpressions": true,
47+
"allowHigherOrderFunctions": true
48+
}
49+
],
50+
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
51+
"@typescript-eslint/explicit-module-boundary-types": "warn",
52+
"@typescript-eslint/member-delimiter-style": "warn",
53+
"@typescript-eslint/method-signature-style": "error",
54+
"@typescript-eslint/member-ordering": "error",
55+
"@typescript-eslint/no-dynamic-delete": "warn",
56+
"@typescript-eslint/no-empty-interface": "off",
57+
"@typescript-eslint/no-extraneous-class": "error",
58+
"@typescript-eslint/no-extra-parens": ["error", "functions"],
59+
"@typescript-eslint/no-extra-semi": "error",
60+
"@typescript-eslint/no-parameter-properties": "error",
61+
"@typescript-eslint/no-unused-expressions": "error",
62+
"@typescript-eslint/no-unused-vars": [
63+
"warn",
64+
{
65+
"vars": "all",
66+
"args": "none",
67+
"argsIgnorePattern": "^_",
68+
"ignoreRestSiblings": true
69+
}
70+
],
71+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
72+
"@typescript-eslint/no-useless-constructor": "warn",
73+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
74+
"@typescript-eslint/prefer-for-of": "error",
75+
"@typescript-eslint/prefer-optional-chain": "error",
76+
"@typescript-eslint/prefer-ts-expect-error": "error",
77+
"@typescript-eslint/quotes": ["error", "single", { "allowTemplateLiterals": true }],
78+
"@typescript-eslint/semi": "error",
79+
"@typescript-eslint/type-annotation-spacing": "error",
80+
"@typescript-eslint/unified-signatures": "error",
81+
"indent": "off",
82+
"sort-keys": "warn"
83+
}
84+
}

.github/workflows/ci.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: volta-cli/action@v1
15+
- uses: actions/[email protected]
16+
with:
17+
path: node_modules
18+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-mongodb
19+
restore-keys: |
20+
${{ runner.os }}-yarn-
21+
- run: yarn install --frozen-lockfile
22+
- run: yarn test:build
23+
24+
lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: volta-cli/action@v1
29+
- uses: actions/[email protected]
30+
with:
31+
path: node_modules
32+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
- run: yarn install --frozen-lockfile
36+
- run: yarn lint
37+
38+
unit:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: volta-cli/action@v1
43+
- uses: actions/[email protected]
44+
with:
45+
path: node_modules
46+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
47+
restore-keys: |
48+
${{ runner.os }}-yarn-
49+
- run: yarn install --frozen-lockfile
50+
- run: yarn test
51+
52+
types:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- uses: volta-cli/action@v1
57+
- uses: actions/[email protected]
58+
with:
59+
path: node_modules
60+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
61+
restore-keys: |
62+
${{ runner.os }}-yarn-
63+
- run: yarn install --frozen-lockfile
64+
- run: yarn test:types

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/build
2+
/cjs
3+
/esm
4+
/tmp
5+
node_modules
6+
tests/*/package-lock.json
7+
tests/*/yarn.lock
8+
yarn-error.log

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

.yarnrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
save-exact true
2+
save-prefix ""

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021-present Plex, Inc.
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.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# papr
2+
3+
![](https://github.com/plexinc/papr/actions/workflows/ci.yaml/badge.svg)
4+
5+
`papr` is a lightweight library built around the MongoDB NodeJS driver, written in TypeScript.
6+
7+
`papr` uses MongoDB's [JSON Schema validation](https://docs.mongodb.com/manual/core/schema-validation/#json-schema) feature to enable validation of document writes at runtime (requires MongoDB 3.6+).
8+
9+
`papr` has a familiar API - if you have used the raw `mongodb` methods to query and change documents before, then you already know how to use `papr`.
10+
11+
## Sample code
12+
13+
<!-- prettier-ignore -->
14+
```ts
15+
import { schema, types } from 'papr';
16+
17+
const papr = new Papr();
18+
19+
const User = papr.model('users', schema({
20+
age: types.number(),
21+
firstName: types.string({ required: true }),
22+
lastName: types.string({ required: true }),
23+
}));
24+
25+
const johnWick = await User.find({ firstName: 'John', lastName: 'Wick' });
26+
```
27+
28+
## Documentation
29+
30+
Read the documentation at: [plexinc.github.io/papr](https://plexinc.github.io/papr/)
31+
32+
## Contributing
33+
34+
This repository is following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
35+
36+
## License
37+
38+
MIT
39+
40+
## Inspiration
41+
42+
- [Mongoose](https://mongoosejs.com/)
43+
- [ts-mongoose](https://github.com/lstkz/ts-mongoose)

babel.config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
],
11+
"@babel/preset-typescript"
12+
]
13+
}

0 commit comments

Comments
 (0)