Skip to content

Commit 5c4f7cd

Browse files
committed
πŸ”– v1.0.0
1 parent 57609de commit 5c4f7cd

File tree

12 files changed

+743
-0
lines changed

12 files changed

+743
-0
lines changed

β€Ž.github/dependabot.yamlβ€Ž

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
assignees:
8+
- "Timeraa"
9+
commit-message:
10+
prefix: "πŸ”Ό"
11+
prefix-development: "πŸ”Ό"
12+
labels:
13+
- "dependencies"
14+
open-pull-requests-limit: 15
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "daily"
19+
assignees:
20+
- "Timeraa"
21+
commit-message:
22+
prefix: "πŸ”Ό"
23+
prefix-development: "πŸ”Ό"
24+
labels:
25+
- "dependencies"
26+
open-pull-requests-limit: 15

β€Ž.github/workflows/CD.ymlβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Package
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v1
14+
with:
15+
registry-url: "https://npm.pkg.github.com"
16+
- run: npm publish
17+
env:
18+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

β€Ž.github/workflows/CI.ymlβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: Build
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-node@v2
10+
with:
11+
node-version: "lts/*"
12+
cache: "yarn"
13+
cache-dependency-path: "**/yarn.lock"
14+
- run: yarn
15+
- run: yarn build
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: CI Dependencies
2+
on:
3+
workflow_run:
4+
workflows: ["CI"]
5+
types:
6+
- completed
7+
jobs:
8+
automerge:
9+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
steps:
14+
- uses: fastify/[email protected]
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
target: minor

β€Ž.gitignoreβ€Ž

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

β€Žlib/index.d.tsβ€Ž

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { DataSource } from "apollo-datasource";
2+
import { KeyValueCache } from "apollo-server-caching";
3+
import { Collection, FindOptions } from "mongodb";
4+
declare type DataSourceOperation = "findOne" | "find" | "count";
5+
export default class MongoDataSource implements DataSource {
6+
cache?: KeyValueCache<string> | undefined;
7+
context: any;
8+
collection: Collection<Document>;
9+
cachePrefix: string;
10+
private pendingResults;
11+
constructor(collection: Collection<Document>, cache?: KeyValueCache<string> | undefined);
12+
initialize({ cache }: {
13+
context: any;
14+
cache: KeyValueCache;
15+
}): void;
16+
count(query?: {}, options?: {
17+
ttl: number;
18+
}): Promise<any>;
19+
find(fields?: any, options?: {
20+
ttl: number;
21+
findOptions?: FindOptions<Document>;
22+
}): Promise<any[]>;
23+
findOne(fields?: any, options?: {
24+
ttl: number;
25+
findOptions?: FindOptions<Document>;
26+
}): Promise<any>;
27+
delete(type: DataSourceOperation, fields: any, options?: {
28+
findOptions?: FindOptions<Document>;
29+
}): Promise<boolean | void | undefined>;
30+
private getCacheKey;
31+
private antiSpam;
32+
}
33+
export {};

β€Žlib/index.jsβ€Ž

Lines changed: 211 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žlib/index.js.mapβ€Ž

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.jsonβ€Ž

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@Recodive/mongodatasource",
3+
"version": "1.0.0",
4+
"description": "An Apollo GraphQL Datasource using MongoDB.",
5+
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
7+
"repository": "https://github.com/Recodive/MongoDataSource.git",
8+
"author": "Timeraa <[email protected]>",
9+
"license": "MPL-2.0",
10+
"scripts": {
11+
"build": "tsc",
12+
"dev": "tsc -w"
13+
},
14+
"dependencies": {
15+
"apollo-datasource": "^3.2.0",
16+
"apollo-server-caching": "^3.2.0",
17+
"mongodb": "^4.1.3"
18+
},
19+
"devDependencies": {
20+
"typescript": "^4.4.4"
21+
}
22+
}

0 commit comments

Comments
Β (0)