Skip to content

Commit 0780a1f

Browse files
authored
Merge pull request #178 from marmelab/modernize
Modernize
2 parents 3dacec7 + f9e76ad commit 0780a1f

Some content is hidden

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

74 files changed

+1752
-4728
lines changed

.eslintrc

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- uses: bahmutov/npm-install@v1
2020
with:
2121
install-command: yarn --immutable
22+
- name: Code quality
23+
run: make lint format
2224
- name: Unit Tests
2325
run: make test
2426
env:

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ watch: ## continuously compile ES6 files to JS
1313
@yarn vite build --watch
1414

1515
test: ## Launch unit tests
16-
@NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest
16+
@yarn run test
1717

1818
watch-test: ## Launch unit tests and watch for changes
19-
@NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest --watch
19+
@yarn run watch-test
20+
21+
check: ## Lint and format the source code
22+
@yarn run check
23+
24+
lint: ## Lint the source code
25+
@yarn run lint
2026

2127
format: ## Format the source code
22-
@./node_modules/.bin/eslint --fix ./src
28+
@yarn run format
2329

2430
run: ## Launch server with example data
25-
@node ./bin/json-graphql-server.cjs example/data.js
31+
@yarn run server
2632

2733
build: ## Build production release
28-
@yarn vite build
29-
@yarn vite build -c ./vite.config.node.js
30-
@yarn vite build -c ./vite.config.umd.js
34+
@yarn run build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Note that the server is [GraphiQL](https://github.com/graphql/graphiql) enabled,
102102
## Install
103103

104104
```sh
105-
npm install json-graphql-server
105+
npm install -D json-graphql-server
106106
```
107107

108108
## Generated Types and Queries
@@ -460,7 +460,7 @@ const data = {
460460
// ... your data
461461
};
462462

463-
app.use('/graphql', jsonGraphqlExpress.default(data));
463+
app.use('/graphql', jsonGraphqlExpress(data));
464464
app.listen(PORT);
465465
```
466466

bin/json-graphql-server.cjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env node
2-
require('reify');
32
var path = require('path');
43
var express = require('express');
54
var cors = require('cors');
6-
var JsonGraphqlServer = require('../dist/json-graphql-server-node.cjs').default;
5+
var { jsonGraphqlExpress } = require('../dist/json-graphql-server-node.cjs');
76
var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json';
87
var data = require(path.resolve(process.cwd(), dataFilePath));
98
var PORT = process.env.NODE_PORT || 3000;
@@ -22,7 +21,7 @@ process.argv.forEach((arg, index) => {
2221
});
2322

2423
app.use(cors());
25-
app.use('/', JsonGraphqlServer(data));
24+
app.use('/', jsonGraphqlExpress(data));
2625
app.listen(PORT, HOST);
2726
var msg = `GraphQL server running with your data at http://${HOST}:${PORT}/`;
2827
console.log(msg); // eslint-disable-line no-console

biome.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"formatter": {
7+
"enabled": true,
8+
"indentStyle": "space",
9+
"indentWidth": 4,
10+
"ignore": ["public/*.js"]
11+
},
12+
"javascript": {
13+
"formatter": {
14+
"quoteStyle": "single"
15+
}
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true,
21+
"suspicious": {
22+
"noExplicitAny": "off"
23+
}
24+
},
25+
"ignore": ["public/*.js"]
26+
}
27+
}

example/index.html renamed to example/browser/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>
77
<button id="button">Load posts</button>
8-
<script src="../dist/json-graphql-server.umd.cjs"></script>
8+
<script src="../../dist/json-graphql-server.umd.cjs"></script>
99
<script type="text/javascript">
1010
window.addEventListener('load', function() {
1111
const data = {
File renamed without changes.

example/node/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Node example
2+
3+
Run it with `node index.mjs`

example/node/index.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import express from 'express';
2+
import jsonGraphqlExpress from '../../dist/json-graphql-server-node.js';
3+
import data from '../data.cjs';
4+
5+
const PORT = 3000;
6+
const app = express();
7+
8+
app.use('/graphql', jsonGraphqlExpress(data));
9+
app.listen(PORT);

0 commit comments

Comments
 (0)