feat: Replace express with native http module

* refactor: replace express with native http module

* fix: 404 when unhandled

* chore: removed express dependency

* chore: updated package-lock.json

* docs: added documentation for BaseHttpServerFactory

* chore: updated package-lock.json

Co-authored-by: Arthur Joppart <arthur@digita.ai>
This commit is contained in:
Stijn Taelemans
2021-02-11 10:15:40 +01:00
committed by GitHub
parent 0ffd332828
commit ce1f4300ff
9 changed files with 90 additions and 400 deletions

View File

@@ -1,6 +1,6 @@
import type { Server } from 'http';
import request from 'supertest';
import type { ExpressHttpServerFactory } from '../../src/server/ExpressHttpServerFactory';
import type { BaseHttpServerFactory } from '../../src/server/BaseHttpServerFactory';
import type { HttpHandlerInput } from '../../src/server/HttpHandler';
import { HttpHandler } from '../../src/server/HttpHandler';
import { StaticAsyncHandler } from '../util/StaticAsyncHandler';
@@ -15,18 +15,18 @@ class SimpleHttpHandler extends HttpHandler {
}
}
describe('An Express server with middleware', (): void => {
describe('An http server with middleware', (): void => {
let server: Server;
beforeAll(async(): Promise<void> => {
const factory = await instantiateFromConfig(
'urn:solid-server:default:ExpressHttpServerFactory', 'server-middleware.json', {
'urn:solid-server:default:HttpServerFactory', 'server-middleware.json', {
'urn:solid-server:default:PodManagerHandler': new StaticAsyncHandler(false, null),
'urn:solid-server:default:LdpHandler': new SimpleHttpHandler(),
'urn:solid-server:default:variable:port': port,
'urn:solid-server:default:variable:baseUrl': 'https://example.pod/',
},
) as ExpressHttpServerFactory;
) as BaseHttpServerFactory;
server = factory.startServer(port);
});