when
is an event-based programming language based on JavaScript, with a few key differences.
when
is not fully procedural, and execution can flow non-linearly through the source code.
A program’s state
consists of:
import 'reflect-metadata'; | |
export interface MachineState { | |
} | |
/** | |
* An activation condition, takes two arguments and must return true for the associated action to fire. | |
*/ | |
export type ActivationCond<State extends MachineState> = | |
(state: Readonly<State>, machine: EventMachine<State>) => boolean; |
A server-side session API for Vulcan.js.
This meteor package provides a session object on the Vulcan.js render context.
The session is stored inside a jsonwebtoken cookie on the client and is automatically saved at the end of each request. (including GraphQL queries)
Particularly useful when used in conjunction with internal-graphql*, which makes GraphQL requests internal to the server process.
To make a GraphQL query on a Vulcan.js server, your server has to connect to itself via a new HTTP connection every time it receives a request.
This package makes it so that Vulcan’s GraphQL queries never leave the process. All GraphQL requests are processed with no overhead.
See also: webtoken-session
const { parse, visit, print, Kind, BREAK } = require('graphql/language'); | |
const { buildASTSchema } = require('graphql/utilities'); | |
const { addResolveFunctionsToSchema } = require('graphql-tools'); | |
const Sequelize = require('sequelize'); | |
const { graphql } = require('graphql'); | |
const jexl = require('jexl'); | |
const deepAssign = require('deep-assign'); | |
const { resolver: sequelizeResolver } = require('graphql-sequelize'); | |
const { inspect } = require('util'); |
import { visit } from 'graphql/language'; | |
/** | |
* Calls directives with a `resolveStatic` hook at the time of parsing. | |
* @param ast GraphQL schema AST. | |
* @param directives The directives collection. | |
* @param throwOnMissing Should we throw if an unknown directive is encountered? | |
* @returns {*} Revised AST as transformed by the directives. | |
*/ | |
export function applyStaticDirectivesToAST(ast, directives, throwOnMissing = true) { |
import { parse, visit, print } = from 'graphql/language'; | |
/** | |
* Combine the fields of two or more AST nodes, does no error checking! | |
* @param types An array with types to combine. | |
* @returns {*} | |
*/ | |
export function combineASTTypes(types) { | |
return types.reduce((p, n) => Object.assign(p, n, { fields: n.fields.concat(p.fields || []) }), {}); | |
} |
import { GraphQLSchema } from 'graphql/type'; | |
import { graphql } from 'graphql'; | |
import { type, query, mutation, field, iface, Schema } from '../src'; | |
class MySchema extends Schema { } | |
/** | |
* Declare a basic interface | |
*/ |
var startTime = Date.now() | |
var fs = require('fs') | |
var Iconv = require('iconv').Iconv | |
var cluster = require('cluster') | |
var workers; | |
if (cluster.isMaster) workers = [1, 2, 3, 4].map(_ => cluster.fork()) | |
if (!cluster.isMaster) | |
{ |