Skip to content

Commit

Permalink
Merge pull request #21 from hatsyjs/v3
Browse files Browse the repository at this point in the history
v3
  • Loading branch information
surol authored Sep 17, 2023
2 parents f2d7c87 + a843593 commit 4eabca6
Show file tree
Hide file tree
Showing 57 changed files with 290 additions and 275 deletions.
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hatsy/hatsy",
"version": "2.5.3",
"version": "3.0.0-pre.0",
"description": "Asynchronous TypeScript-friendly HTTP server for Node.js",
"keywords": [
"http-framework",
Expand All @@ -22,10 +22,10 @@
"types": "./dist/hatsy.d.ts",
"typesVersions": {
"*": {
"core": [
"core.js": [
"./dist/hatsy.core.d.ts"
],
"testing": [
"testing.js": [
"./dist/hatsy.testing.d.ts"
]
}
Expand All @@ -35,30 +35,28 @@
"types": "./dist/hatsy.d.ts",
"default": "./dist/hatsy.js"
},
"./core": {
"./core.js": {
"types": "./dist/hatsy.core.d.ts",
"default": "./dist/hatsy.core.js"
},
"./package.json": "./package.json",
"./testing": {
"./testing.js": {
"types": "./dist/hatsy.testing.d.ts",
"default": "./dist/hatsy.testing.js"
}
},
"sideEffects": false,
"dependencies": {
"@frontmeans/httongue": "^2.4.0",
"@hatsy/http-header-value": "^3.7.1",
"@proc7ts/logger": "^1.3.2",
"@proc7ts/primitives": "^3.0.2"
"@proc7ts/logger": "^2.0.0",
"@proc7ts/primitives": "^4.0.1",
"httongue": "^3.1.0",
"http-header-value": "^4.0.0"
},
"engines": {
"node": ">=12"
"node": ">=18"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@proc7ts/context-values": "^7.1.1",
"@proc7ts/logger": "^1.3.2",
"@run-z/eslint-config": "^3.5.0",
"@run-z/prettier-config": "^2.0.0",
"@run-z/project-config": "^0.20.0",
Expand Down
6 changes: 3 additions & 3 deletions src/core/dispatch-error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ErrorMeans } from './error.means';
import type { RequestHandler } from './request-handler';
import { requestExtension } from './request-modification';
import type { ErrorMeans } from './error.means.js';
import type { RequestHandler } from './request-handler.js';
import { requestExtension } from './request-modification.js';

/**
* Dispatches request processing error.
Expand Down
14 changes: 0 additions & 14 deletions src/core/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/core/logging/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/logging/logger.means.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestLogger } from './request-logger';
import type { RequestLogger } from './request-logger.js';

/**
* Request logger means.
Expand Down
10 changes: 5 additions & 5 deletions src/core/logging/logging.capability.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { consoleLogger } from '@proc7ts/logger';
import { RequestCapability } from '../request-capability';
import type { RequestHandler } from '../request-handler';
import { requestExtension } from '../request-modification';
import type { LoggerMeans } from './logger.means';
import type { RequestLogger } from './request-logger';
import { RequestCapability } from '../request-capability.js';
import type { RequestHandler } from '../request-handler.js';
import { requestExtension } from '../request-modification.js';
import type { LoggerMeans } from './logger.means.js';
import type { RequestLogger } from './request-logger.js';

/**
* Request logging capability.
Expand Down
14 changes: 7 additions & 7 deletions src/core/logging/logging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { consoleLogger, silentLogger } from '@proc7ts/logger';
import { noop } from '@proc7ts/primitives';
import type { Mock } from 'jest-mock';
import type { RequestContext } from '../request-context';
import type { RequestHandler } from '../request-handler';
import type { RequestProcessor } from '../request-processor';
import { requestProcessor } from '../request-processor';
import type { LoggerMeans } from './logger.means';
import { Logging } from './logging.capability';
import type { RequestLogger } from './request-logger';
import type { RequestContext } from '../request-context.js';
import type { RequestHandler } from '../request-handler.js';
import type { RequestProcessor } from '../request-processor.js';
import { requestProcessor } from '../request-processor.js';
import type { LoggerMeans } from './logger.means.js';
import { Logging } from './logging.capability.js';
import type { RequestLogger } from './request-logger.js';

describe('Logging', () => {
let handler: Mock<(context: RequestContext<LoggerMeans>) => void>;
Expand Down
3 changes: 3 additions & 0 deletions src/core/logging/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './logger.means.js';
export * from './logging.capability.js';
export * from './request-logger.js';
13 changes: 13 additions & 0 deletions src/core/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @module @hatsy/hatsy/core.js
*/
export * from './dispatch-error.js';
export * from './error.means.js';
export * from './logging/mod.js';
export * from './request-body.means.js';
export * from './request-capability.js';
export * from './request-context.js';
export * from './request-handler.js';
export * from './request-modification.js';
export * from './request-processor.js';
export * from './request-value-transformer.js';
2 changes: 1 addition & 1 deletion src/core/request-capability.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestHandler } from './request-handler';
import type { RequestHandler } from './request-handler.js';

/**
* Request processing capability.
Expand Down
4 changes: 2 additions & 2 deletions src/core/request-context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RequestHandler } from './request-handler';
import type { RequestModification } from './request-modification';
import type { RequestHandler } from './request-handler.js';
import type { RequestModification } from './request-modification.js';

/**
* Request processing context.
Expand Down
4 changes: 2 additions & 2 deletions src/core/request-handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { beforeEach, describe, expect, it } from '@jest/globals';
import { valueProvider } from '@proc7ts/primitives';
import type { ServerResponse } from 'node:http';
import type { RequestContext } from './request-context';
import { requestHandler, RequestHandler } from './request-handler';
import type { RequestContext } from './request-context.js';
import { requestHandler, RequestHandler } from './request-handler.js';

describe('requestHandler', () => {
let context: RequestContext<object>;
Expand Down
4 changes: 2 additions & 2 deletions src/core/request-handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { RequestContext } from './request-context';
import type { RequestContext } from './request-context.js';

/**
* Request processing handler signature.
*
* Handler implementations expect a request processing context containing specific processing means.
* E.g. the ones for {@link HttpMeans HTTP request processing}. The handler may either respond using the provided means,
* or delegate to {@link RequestContext.Agent.next next handler}.
* or delegate to {@link RequestContext.Agent#next next handler}.
*
* The handler may be asynchronous.
*
Expand Down
6 changes: 3 additions & 3 deletions src/core/request-processor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RequestContext } from './request-context';
import type { RequestHandler, RequestHandlerMethod } from './request-handler';
import type { RequestModification } from './request-modification';
import type { RequestContext } from './request-context.js';
import type { RequestHandler, RequestHandlerMethod } from './request-handler.js';
import type { RequestModification } from './request-modification.js';

/**
* Generic request processor.
Expand Down
2 changes: 1 addition & 1 deletion src/core/request-value-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RequestContext } from './request-context';
import type { RequestContext } from './request-context.js';

/**
* Signature of request value transformer function.
Expand Down
15 changes: 8 additions & 7 deletions src/http/dispatch/dispatch-by-accepted.handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
import { silentLogger } from '@proc7ts/logger';
import type { RequestContext } from '../../core';
import { Logging } from '../../core';
import { TestHttpServer } from '../../testing';
import type { HttpMeans } from '../http.means';
import { Rendering, RenderMeans } from '../render';
import { addResponseHeader } from '../util';
import { dispatchByAccepted } from './dispatch-by-accepted.handler';
import { Logging } from '../../core/logging/logging.capability.js';
import { RequestContext } from '../../core/request-context.js';
import { TestHttpServer } from '../../testing/test-http-server.js';
import { HttpMeans } from '../http.means.js';
import { RenderMeans } from '../render/render.means.js';
import { Rendering } from '../render/rendering.capability.js';
import { addResponseHeader } from '../util/add-response-header.js';
import { dispatchByAccepted } from './dispatch-by-accepted.handler.js';

describe('dispatchByAccepted', () => {
let server: TestHttpServer;
Expand Down
10 changes: 5 additions & 5 deletions src/http/dispatch/dispatch-by-accepted.handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { httpMimeNegotiator } from '@hatsy/http-header-value/headers';
import type { RequestHandler, RequestHandlerMethod } from '../../core';
import { HttpError } from '../http-error';
import type { HttpMeans } from '../http.means';
import { addResponseHeader } from '../util';
import { httpMimeNegotiator } from 'http-header-value/headers.js';
import { HttpError } from '../http-error.js';
import type { HttpMeans } from '../http.means.js';
import { RequestHandler, RequestHandlerMethod } from '../../core/request-handler.js';
import { addResponseHeader } from '../util/add-response-header.js';

/**
* Request processing handlers for accepted MIME types.
Expand Down
8 changes: 4 additions & 4 deletions src/http/dispatch/dispatch-by-language.handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
import { silentLogger } from '@proc7ts/logger';
import { Logging } from '../../core';
import { TestHttpServer } from '../../testing';
import { Rendering } from '../render';
import { dispatchByLanguage } from './dispatch-by-language.handler';
import { Logging } from '../../core/logging/logging.capability.js';
import { TestHttpServer } from '../../testing/test-http-server.js';
import { Rendering } from '../render/rendering.capability.js';
import { dispatchByLanguage } from './dispatch-by-language.handler.js';

describe('dispatchByLanguage', () => {
let server: TestHttpServer;
Expand Down
10 changes: 5 additions & 5 deletions src/http/dispatch/dispatch-by-language.handler.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { httpLanguageNegotiator } from '@hatsy/http-header-value/headers';
import type { RequestHandler, RequestHandlerMethod } from '../../core';
import { HttpError } from '../http-error';
import type { HttpMeans } from '../http.means';
import { addResponseHeader } from '../util';
import { httpLanguageNegotiator } from 'http-header-value/headers.js';
import { RequestHandler, RequestHandlerMethod } from '../../core/request-handler.js';
import { HttpError } from '../http-error.js';
import type { HttpMeans } from '../http.means.js';
import { addResponseHeader } from '../util/add-response-header.js';

/**
* Request processing handlers for accepted languages.
Expand Down
15 changes: 9 additions & 6 deletions src/http/dispatch/dispatch-by-method.handler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
import { silentLogger } from '@proc7ts/logger';
import { noop } from '@proc7ts/primitives';
import { Logging, RequestContext, requestHandler } from '../../core';
import { TestHttpServer } from '../../testing';
import { HttpError } from '../http-error';
import type { HttpMeans } from '../http.means';
import { Rendering, RenderMeans } from '../render';
import { dispatchByMethod } from './dispatch-by-method.handler';
import { TestHttpServer } from '../../testing/test-http-server.js';
import { Rendering } from '../render/rendering.capability.js';
import { dispatchByMethod } from './dispatch-by-method.handler.js';
import { RequestContext } from '../../core/request-context.js';
import { HttpMeans } from '../http.means.js';
import { RenderMeans } from '../render/render.means.js';
import { requestHandler } from '../../core/request-handler.js';
import { Logging } from '../../core/logging/logging.capability.js';
import { HttpError } from '../http-error.js';

describe('dispatchByName', () => {
let server: TestHttpServer;
Expand Down
4 changes: 2 additions & 2 deletions src/http/dispatch/dispatch-by-method.handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RequestHandler, RequestHandlerMethod } from '../../core';
import type { HttpMeans } from '../http.means';
import { RequestHandler, RequestHandlerMethod } from '../../core/request-handler.js';
import type { HttpMeans } from '../http.means.js';

/**
* Request processing handlers for HTTP request methods.
Expand Down
3 changes: 0 additions & 3 deletions src/http/dispatch/index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/http/dispatch/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './dispatch-by-accepted.handler.js';
export * from './dispatch-by-language.handler.js';
export * from './dispatch-by-method.handler.js';
5 changes: 3 additions & 2 deletions src/http/http-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ErrorMeans, RequestHandler } from '../core';
import type { HttpMeans } from './http.means';
import { ErrorMeans } from '../core/error.means.js';
import { RequestHandler } from '../core/request-handler.js';
import type { HttpMeans } from './http.means.js';

/**
* HTTP processing configuration.
Expand Down
8 changes: 4 additions & 4 deletions src/http/http-error.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from '@jest/globals';
import { dueLog } from '@proc7ts/logger';
import { HttpError } from './http-error';
import { HttpError } from './http-error.js';

describe('HttpError', () => {
describe('message', () => {
Expand Down Expand Up @@ -33,11 +33,11 @@ describe('HttpError', () => {
]);
});
it('expands reason at output stage', () => {
const reason = new Error('test');
const cause = new Error('test');

expect(dueLog({ on: 'out', line: [new HttpError(500, { reason })] }).line).toEqual([
expect(dueLog({ on: 'out', line: [new HttpError(500, { cause })] }).line).toEqual([
'500',
reason,
cause,
]);
});
});
Expand Down
Loading

0 comments on commit 4eabca6

Please sign in to comment.