Skip to content

Commit 041c960

Browse files
authored
Merge pull request #4 from inaiat/chore/update-libs-and-put-papr-as-peer-dep
Chore/update libs and put papr as peer dep
2 parents cf88a81 + 222ccaf commit 041c960

12 files changed

+451
-453
lines changed

BUILD_SHA

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
327d547f9a182c658c5ef4585679f38867499101

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# fastify-papr
2+
![Statements](https://img.shields.io/badge/statements-98.75%25-brightgreen.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-85%25-yellow.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-100%25-brightgreen.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-98.75%25-brightgreen.svg?style=flat)
23

34
A fastify Papr plugin integration.
45

@@ -71,4 +72,10 @@ export default userRoute
7172

7273
## Papr Documentation
7374

74-
Read the documentation at: [plexinc.github.io/papr](https://plexinc.github.io/papr/)
75+
Read the documentation at: [plexinc.github.io/papr](https://plexinc.github.io/papr/)
76+
77+
## ESM Only
78+
79+
This package only supports to be directly imported in a ESM context.
80+
81+
For informations on how to use it in a CommonJS context, please check [this page](https://gist.github.com/ShogunPanda/fe98fd23d77cdfb918010dbc42f4504d).

package-lock.json

+399-425
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inaiat/fastify-papr",
3-
"version": "0.0.9",
3+
"version": "1.0.0",
44
"description": "Fastify Papr Plugin Integration",
55
"type": "module",
66
"engines": {
@@ -12,7 +12,9 @@
1212
"test": "xo && ava",
1313
"build": "rimraf ./dist && mkdir dist && tsc --outDir dist && git rev-parse HEAD > BUILD_SHA",
1414
"lint": "xo --fix",
15-
"prepublishOnly": "npm run build"
15+
"coverage": "xo && c8 ava",
16+
"prepublishOnly": "npm run build",
17+
"make-badges": "istanbul-badges-readme"
1618
},
1719
"repository": {
1820
"type": "git",
@@ -44,28 +46,28 @@
4446
],
4547
"homepage": "https://github.com/inaiat/fastify-papr.git",
4648
"dependencies": {
47-
"fastify-plugin": "^4.2.0",
48-
"papr": "^7.2.1"
49+
"fastify-plugin": "^4.2.1"
4950
},
5051
"peerDependencies": {
51-
"fastify": "^4.5.0",
52-
"mongodb": "^4.8.1"
52+
"fastify": "^4.5.3",
53+
"mongodb": "^4.9.0",
54+
"papr": "^7.x"
5355
},
5456
"devDependencies": {
5557
"@swc/cli": "^0.1.57",
56-
"@swc/core": "^1.2.237",
57-
"@swc/helpers": "^0.4.6",
58-
"@types/node": "^18.7.6",
58+
"@swc/core": "^1.2.245",
59+
"@swc/helpers": "^0.4.11",
60+
"@types/node": "^18.7.14",
5961
"@types/semver": "^7.3.12",
60-
"ava": "^4.3.1",
62+
"ava": "^4.3.3",
6163
"c8": "^7.12.0",
62-
"fastify": "^4.5.0",
6364
"mongodb-memory-server": "^8.8.0",
6465
"rimraf": "^3.0.2",
6566
"semver": "^7.3.7",
6667
"ts-node": "^10.9.1",
67-
"typescript": "^4.7.4",
68-
"xo": "^0.51.0"
68+
"typescript": "^4.8.2",
69+
"xo": "^0.52.2",
70+
"istanbul-badges-readme": "^1.8.2"
6971
},
7072
"files": [
7173
"dist"
@@ -81,6 +83,13 @@
8183
"--loader=ts-node/esm"
8284
]
8385
},
86+
"c8": {
87+
"reporter": [
88+
"text",
89+
"json-summary",
90+
"lcov"
91+
]
92+
},
8493
"xo": {
8594
"semicolon": false,
8695
"ignores": [
@@ -102,7 +111,8 @@
102111
"@typescript-eslint/no-redundant-type-constituents": "off",
103112
"no-lone-blocks": "off",
104113
"unicorn/no-await-expression-member": "off",
105-
"@typescript-eslint/naming-convention": "off"
114+
"@typescript-eslint/naming-convention": "off",
115+
"@typescript-eslint/consistent-type-definitions": "off"
106116
}
107117
},
108118
"config": {

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fp from 'fastify-plugin'
2-
import {BaseSchema, Model} from 'papr'
3-
import {FastifyPaprOptions, PaprModels} from './types.js'
2+
import type {BaseSchema, Model} from 'papr'
3+
import type {FastifyPaprOptions, PaprModels} from './types.js'
44
import {paprHelper} from './papr-helper.js'
55

66
export const asModel = <TSchema extends BaseSchema>(
@@ -22,7 +22,7 @@ const fastifyPaprPlugin = fp<FastifyPaprOptions>(
2222
}
2323

2424
if (fastify.papr[name]) {
25-
throw new Error('Connection name already registered: ' + name)
25+
throw new Error(`Connection name already registered: ${name}`)
2626
}
2727

2828
fastify.papr[name] = models as Model<any, any> & PaprModels

src/papr-helper.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {FastifyInstance} from 'fastify'
2-
import {Db} from 'mongodb'
3-
import Papr, {BaseSchema} from 'papr'
4-
import {ModelRegistrationPair, PaprModels} from './types.js'
1+
import type {FastifyInstance} from 'fastify'
2+
import type {Db} from 'mongodb'
3+
import type {BaseSchema} from 'papr'
4+
import Papr from 'papr'
5+
import type {ModelRegistrationPair, PaprModels} from './types.js'
56

67
export const paprHelper = (fastify: FastifyInstance, db: Db) => {
78
const papr = new Papr()

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {Model} from 'papr'
22
import type {Db} from 'mongodb'
3-
import {asModel} from './index.js'
3+
import type {asModel} from './index.js'
44

55
export type PaprModelItem = ReturnType<typeof asModel>
66

tests/helpers/server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {fastify} from 'fastify'
2-
import anyTest, {TestFn} from 'ava'
2+
import type {TestFn} from 'ava'
3+
import anyTest from 'ava'
34
import {MongoMemoryServer} from 'mongodb-memory-server'
45
import {MongoClient} from 'mongodb'
56

tests/muliple.col.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {Model, schema, types} from 'papr'
1+
import type {Model} from 'papr'
2+
import {schema, types} from 'papr'
23
import test from 'ava'
34
import {MongoClient, MongoServerError} from 'mongodb'
45
import fastifyPaprPlugin, {asModel} from '../src/index.js'

tests/multi.db.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {Model, schema, types} from 'papr'
1+
import type {Model} from 'papr'
2+
import {schema, types} from 'papr'
23
import test from 'ava'
34
import {MongoClient} from 'mongodb'
45
import fastifyPaprPlugin, {asModel} from '../src/index.js'

tests/simple.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {Model, schema, types, BaseSchema} from 'papr'
1+
import type {Model} from 'papr'
2+
import {schema, types, BaseSchema} from 'papr'
23
import {MongoServerError} from 'mongodb'
34
import fastifyPaprPlugin, {asModel} from '../src/index.js'
45
import {getConfiguredTestServer, test} from './helpers/server.js'

tests/validation.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {Model, schema, types} from 'papr'
1+
import type {Model} from 'papr'
2+
import {schema, types} from 'papr'
23
import {MongoServerError} from 'mongodb'
34
import fastifyPaprPlugin, {asModel} from '../src/index.js'
45
import {SimpleDocFailedValidationError} from '../src/simple-doc-failed-validation.js'

0 commit comments

Comments
 (0)