Skip to content

Commit

Permalink
feat: added prettier and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Nov 5, 2023
1 parent c543df0 commit c06a800
Show file tree
Hide file tree
Showing 19 changed files with 5,338 additions and 1,587 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jest.config.js
test/*
.mesh/*
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
4 changes: 3 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build PR

on:
pull_request:
branches: ["main"]
branches: ['main']

jobs:
build:
Expand All @@ -14,6 +14,8 @@ jobs:
run: npm install -g pnpm@7.33.5
- name: Install Project Dependencies
run: pnpm install
- name: Run Eslint
run: pnpm lint
- name: Replace F1 with F2 content
run: cp custom-fetch-backup.ts custom-fetch.ts
- name: Build Graphql queries
Expand Down
2 changes: 1 addition & 1 deletion .meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sources:
handler:
graphql:
endpoint: https://develop.protocol.mygateway.xyz/v1/graphql
method: "POST"
method: 'POST'
useGETForQueries: false

customFetch: ./custom-fetch.ts
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ POC made using graphql mesh
```sh
pnpm dev
```

17 changes: 4 additions & 13 deletions custom-fetch-backup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Headers, fetch } from "@whatwg-node/fetch";
import { MeshContext } from "@graphql-mesh/runtime";
import { fetch } from '@whatwg-node/fetch';
import { MeshContext } from '@graphql-mesh/runtime';

type ContextModified = MeshContext & {
token: string;
Expand All @@ -9,17 +9,8 @@ type ContextModified = MeshContext & {
export default function patchedFetch(
url: string,
init: RequestInit,
context: ContextModified
context: ContextModified,
) {
// const headers = new Headers();
// headers.set(
// "accept",
// "application/graphql-response+json application/json multipart/mixed"
// );
// headers.set("content-type", "application/json");
// headers.set("Authorization", `Bearer ${context?.token}`);
// headers.set("X-Api-Key", context?.apiKey);
// init.headers = headers;
// console.log(url, init);
context.apiKey;
return fetch(url, init);
}
16 changes: 8 additions & 8 deletions custom-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Headers, fetch } from "@whatwg-node/fetch";
import { MeshContext } from "@graphql-mesh/runtime";
import { Headers, fetch } from '@whatwg-node/fetch';
import { MeshContext } from '@graphql-mesh/runtime';

type ContextModified = MeshContext & {
token: string;
Expand All @@ -9,16 +9,16 @@ type ContextModified = MeshContext & {
export default function patchedFetch(
url: string,
init: RequestInit,
context: ContextModified
context: ContextModified,
) {
const headers = new Headers();
headers.set(
"accept",
"application/graphql-response+json application/json multipart/mixed"
'accept',
'application/graphql-response+json application/json multipart/mixed',
);
headers.set("content-type", "application/json");
headers.set("Authorization", `Bearer ${context?.token}`);
headers.set("X-Api-Key", context?.apiKey);
headers.set('content-type', 'application/json');
headers.set('Authorization', `Bearer ${context?.token}`);
headers.set('X-Api-Key', context?.apiKey);
init.headers = headers;
console.log(url, init);
return fetch(url, init);
Expand Down
30 changes: 0 additions & 30 deletions index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
};
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"main": "index.js",
"scripts": {
"test": "jest",
"dev": "ts-node ./index.ts"
"dev": "ts-node ./index.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write ."
},
"keywords": [],
"author": "",
Expand All @@ -20,7 +23,16 @@
},
"devDependencies": {
"@types/jest": "^29.5.7",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.0.0",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
Expand Down
Loading

0 comments on commit c06a800

Please sign in to comment.