chore: Remove initServerStore.

This commit is contained in:
Ruben Verborgh 2020-12-20 14:48:29 +01:00
parent 53479eb557
commit 6e2c4f0ccf
3 changed files with 2 additions and 26 deletions

View File

@ -1,8 +1,6 @@
import type { Server } from 'http';
import { join } from 'path'; import { join } from 'path';
import * as Path from 'path'; import * as Path from 'path';
import { Loader } from 'componentsjs'; import { Loader } from 'componentsjs';
import fetch from 'cross-fetch';
import type { import type {
BodyParser, BodyParser,
DataAccessor, DataAccessor,
@ -26,7 +24,6 @@ import {
ErrorResponseWriter, ErrorResponseWriter,
GetOperationHandler, GetOperationHandler,
HeadOperationHandler, HeadOperationHandler,
HttpError,
InMemoryDataAccessor, InMemoryDataAccessor,
LinkRelMetadataWriter, LinkRelMetadataWriter,
LinkTypeParser, LinkTypeParser,
@ -195,22 +192,3 @@ export const instantiateFromConfig = async(componentUrl: string, configFile: str
const configPath = Path.join(__dirname, configFile); const configPath = Path.join(__dirname, configFile);
return loader.instantiateFromUrl(componentUrl, configPath, undefined, { variables }); return loader.instantiateFromUrl(componentUrl, configPath, undefined, { variables });
}; };
/**
* Initializes the root container of the server.
* Useful for when the RootContainerInitializer was not instantiated.
*/
export const initServerStore = async(server: Server, baseUrl: string,
headers: Record<string, string> = {}): Promise<void> => {
const res = await fetch(baseUrl, {
method: 'PUT',
headers: {
...headers,
'content-type': 'text/turtle',
},
body: '',
});
if (res.status >= 400) {
throw new HttpError(res.status, 'Error', res.statusText);
}
};

View File

@ -3,7 +3,7 @@ import { join } from 'path';
import fetch from 'cross-fetch'; import fetch from 'cross-fetch';
import type { HttpServerFactory } from '../../src/server/HttpServerFactory'; import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
import { readableToString } from '../../src/util/StreamUtil'; import { readableToString } from '../../src/util/StreamUtil';
import { initServerStore, instantiateFromConfig } from '../configs/Util'; import { instantiateFromConfig } from '../configs/Util';
const port = 6003; const port = 6003;
const baseUrl = `http://localhost:${port}/`; const baseUrl = `http://localhost:${port}/`;
@ -21,7 +21,6 @@ describe('A server with a pod handler', (): void => {
}, },
) as HttpServerFactory; ) as HttpServerFactory;
server = factory.startServer(port); server = factory.startServer(port);
await initServerStore(server, baseUrl);
}); });
afterAll(async(): Promise<void> => { afterAll(async(): Promise<void> => {

View File

@ -2,7 +2,7 @@ import type { Server } from 'http';
import fetch from 'cross-fetch'; import fetch from 'cross-fetch';
import WebSocket from 'ws'; import WebSocket from 'ws';
import type { HttpServerFactory } from '../../src/server/HttpServerFactory'; import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
import { initServerStore, instantiateFromConfig } from '../configs/Util'; import { instantiateFromConfig } from '../configs/Util';
const port = 6001; const port = 6001;
const serverUrl = `http://localhost:${port}/`; const serverUrl = `http://localhost:${port}/`;
@ -20,7 +20,6 @@ describe('A server with the Solid WebSockets API behind a proxy', (): void => {
}, },
) as HttpServerFactory; ) as HttpServerFactory;
server = factory.startServer(port); server = factory.startServer(port);
await initServerStore(server, serverUrl, headers);
}); });
afterAll(async(): Promise<void> => { afterAll(async(): Promise<void> => {