Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Cors to the server (#25)

## [0.2.3] - 2025-09-11
### Changed
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@graphile/simplify-inflection": "^8.0.0-beta.8",
"@subql/utils": "^2.14.0",
"@types/yargs": "^17.0.33",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"eslint": "^8.8.0",
"express": "^4.21.1",
Expand All @@ -34,6 +35,7 @@
"@apollo/client": "3.0.0",
"@geut/chan": "^3.2.9",
"@tsconfig/node20": "^20.1.4",
"@types/cors": "^2.8.19",
"@types/express": "^4",
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^5",
Expand Down
3 changes: 3 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0

import { createServer, Server } from 'node:http';
import cors from 'cors';
import express from 'express';
import { grafserv } from 'grafserv/express/v4';
import { postgraphile } from 'postgraphile';
Expand All @@ -22,6 +23,8 @@ export function startServer(args: ArgsInterface): Server {
next();
});

app.use(cors());

const server = createServer(app);

server.on('error', (e) => {
Expand Down
8 changes: 8 additions & 0 deletions test/subgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ describe('subgraph plugin test', () => {
await pool.end();
});

it('can make an OPTIONS request', async () => {
const res = await fetch('http://localhost:3001', {
method: 'OPTIONS',
});

expect(res.ok).toBeTruthy();
});

describe('_meta plugin', () => {
it('query _meta', async () => {
await Promise.all([
Expand Down
25 changes: 23 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1440,11 +1440,13 @@ __metadata:
"@graphile/simplify-inflection": ^8.0.0-beta.8
"@subql/utils": ^2.14.0
"@tsconfig/node20": ^20.1.4
"@types/cors": ^2.8.19
"@types/express": ^4
"@types/jest": ^29.5.12
"@types/yargs": ^17.0.33
"@typescript-eslint/eslint-plugin": ^5
"@typescript-eslint/parser": 5
cors: ^2.8.5
dotenv: ^16.4.5
eslint: ^8.8.0
eslint-config-prettier: ^8.3.0
Expand Down Expand Up @@ -1641,6 +1643,15 @@ __metadata:
languageName: node
linkType: hard

"@types/cors@npm:^2.8.19":
version: 2.8.19
resolution: "@types/cors@npm:2.8.19"
dependencies:
"@types/node": "*"
checksum: 9545cc532c9218754443f48a0c98c1a9ba4af1fe54a3425c95de75ff3158147bb39e666cb7c6bf98cc56a9c6dc7b4ce5b2cbdae6b55d5942e50c81b76ed6b825
languageName: node
linkType: hard

"@types/debug@npm:^4.1.7":
version: 4.1.12
resolution: "@types/debug@npm:4.1.12"
Expand Down Expand Up @@ -2872,6 +2883,16 @@ __metadata:
languageName: node
linkType: hard

"cors@npm:^2.8.5":
version: 2.8.5
resolution: "cors@npm:2.8.5"
dependencies:
object-assign: ^4
vary: ^1
checksum: ced838404ccd184f61ab4fdc5847035b681c90db7ac17e428f3d81d69e2989d2b680cc254da0e2554f5ed4f8a341820a1ce3d1c16b499f6e2f47a1b9b07b5006
languageName: node
linkType: hard

"create-jest@npm:^29.7.0":
version: 29.7.0
resolution: "create-jest@npm:29.7.0"
Expand Down Expand Up @@ -6540,7 +6561,7 @@ __metadata:
languageName: node
linkType: hard

"object-assign@npm:^4.1.0, object-assign@npm:^4.1.1":
"object-assign@npm:^4, object-assign@npm:^4.1.0, object-assign@npm:^4.1.1":
version: 4.1.1
resolution: "object-assign@npm:4.1.1"
checksum: fcc6e4ea8c7fe48abfbb552578b1c53e0d194086e2e6bbbf59e0a536381a292f39943c6e9628af05b5528aa5e3318bb30d6b2e53cadaf5b8fe9e12c4b69af23f
Expand Down Expand Up @@ -8876,7 +8897,7 @@ __metadata:
languageName: node
linkType: hard

"vary@npm:~1.1.2":
"vary@npm:^1, vary@npm:~1.1.2":
version: 1.1.2
resolution: "vary@npm:1.1.2"
checksum: ae0123222c6df65b437669d63dfa8c36cee20a504101b2fcd97b8bf76f91259c17f9f2b4d70a1e3c6bbcee7f51b28392833adb6b2770b23b01abec84e369660b
Expand Down
Loading