Initialisation

Added the packages and files for the backend server
This commit is contained in:
jackbeeby
2024-12-15 17:48:45 +11:00
parent 25066e1ee8
commit b412dfe2ca
2732 changed files with 330572 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/// <reference types="node" />
/// <reference types="node" />
import type { WithRequired } from '@apollo/utils.withrequired';
import { type IncomingMessage, type ServerResponse } from 'http';
import type { ListenOptions } from 'net';
import type { ApolloServer } from '../ApolloServer.js';
import type { BaseContext, ContextFunction } from '../externalTypes/index.js';
export interface StandaloneServerContextFunctionArgument {
req: IncomingMessage;
res: ServerResponse;
}
export interface StartStandaloneServerOptions<TContext extends BaseContext> {
context?: ContextFunction<[
StandaloneServerContextFunctionArgument
], TContext>;
}
export declare function startStandaloneServer(server: ApolloServer<BaseContext>, options?: StartStandaloneServerOptions<BaseContext> & {
listen?: ListenOptions;
}): Promise<{
url: string;
}>;
export declare function startStandaloneServer<TContext extends BaseContext>(server: ApolloServer<TContext>, options: WithRequired<StartStandaloneServerOptions<TContext>, 'context'> & {
listen?: ListenOptions;
}): Promise<{
url: string;
}>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/standalone/index.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAa,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAY9E,MAAM,WAAW,uCAAuC;IACtD,GAAG,EAAE,eAAe,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B,CAAC,QAAQ,SAAS,WAAW;IACxE,OAAO,CAAC,EAAE,eAAe,CACvB;QAAC,uCAAuC;KAAC,EACzC,QAAQ,CACT,CAAC;CACH;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,EACjC,OAAO,CAAC,EAAE,4BAA4B,CAAC,WAAW,CAAC,GAAG;IACpD,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,GACA,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC5B,wBAAsB,qBAAqB,CAAC,QAAQ,SAAS,WAAW,EACtE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,EAC9B,OAAO,EAAE,YAAY,CAAC,4BAA4B,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,GAAG;IACzE,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,GACA,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC"}

View File

@@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.startStandaloneServer = void 0;
const cors_1 = __importDefault(require("cors"));
const express_1 = __importDefault(require("express"));
const http_1 = __importDefault(require("http"));
const index_js_1 = require("../express4/index.js");
const index_js_2 = require("../plugin/drainHttpServer/index.js");
const urlForHttpServer_js_1 = require("../utils/urlForHttpServer.js");
async function startStandaloneServer(server, options) {
const app = (0, express_1.default)();
const httpServer = http_1.default.createServer(app);
server.addPlugin((0, index_js_2.ApolloServerPluginDrainHttpServer)({ httpServer: httpServer }));
await server.start();
const context = options?.context ?? (async () => ({}));
app.use((0, cors_1.default)(), express_1.default.json({ limit: '50mb' }), (0, index_js_1.expressMiddleware)(server, { context }));
const listenOptions = options?.listen ?? { port: 4000 };
await new Promise((resolve) => {
httpServer.listen(listenOptions, resolve);
});
return { url: (0, urlForHttpServer_js_1.urlForHttpServer)(httpServer) };
}
exports.startStandaloneServer = startStandaloneServer;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/standalone/index.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AACxB,sDAA8B;AAC9B,gDAAuE;AAGvE,mDAAyD;AAEzD,iEAAuF;AACvF,sEAAgE;AAkCzD,KAAK,UAAU,qBAAqB,CACzC,MAA8B,EAC9B,OAA6E;IAE7E,MAAM,GAAG,GAAoB,IAAA,iBAAO,GAAE,CAAC;IACvC,MAAM,UAAU,GAAgB,cAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAEvD,MAAM,CAAC,SAAS,CACd,IAAA,4CAAiC,EAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAC9D,CAAC;IAEF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAa,CAAC,CAAC;IACnE,GAAG,CAAC,GAAG,CACL,IAAA,cAAI,GAAE,EACN,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAC/B,IAAA,4BAAiB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CACvC,CAAC;IAEF,MAAM,aAAa,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAExD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,IAAA,sCAAgB,EAAC,UAAU,CAAC,EAAE,CAAC;AAC/C,CAAC;AA3BD,sDA2BC"}