Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
3.5: Static bundling, WebSocket subscriptions
Browse files Browse the repository at this point in the history
- Adds WebSocket support to real-time `subscription` queries
- Adds `.env` file for managing environment variables
- Adds `GRAPHQL` variable to `.env`, to specify GraphQL server/endpoint
- Adds `WS_SUBSCRIPTIONS` variable to `.env`, to enable/disable WebSockets
- Adds `npm run static` mode, for building a client-only static bundle
- Adds `src/views/index.html` template for static bundling
- Refactors `src/runner/app.ts` to allow static compilation
  • Loading branch information
leebenson committed Oct 11, 2018
1 parent 40ef689 commit add4eb6
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GRAPHQL=https://graphqlhub.com/graphql
WS_SUBSCRIPTIONS=0
12 changes: 5 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// Run the right environment...

// Load env vars, for the `GRAPHQL` endpoint and anything else we need
require("dotenv").config();

// Catch CTRL/CMD+C interrupts cleanly
process.on("SIGINT", () => {
process.exit();
});

// Build mode?
let script: string;

if (process.env.npm_lifecycle_event === "build") {
script = "build";
} else {
script = process.env.NODE_ENV === "production" ? "production" : "development";
}
const script = ["build", "static"].includes(process.env.npm_lifecycle_event!)
? process.env.npm_lifecycle_event! : process.env.NODE_ENV || "development";

// Start the script
require(`./src/runner/${script}`);
Loading

0 comments on commit add4eb6

Please sign in to comment.