-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - Server 'start' method. - Default config to server module. - HttpConnection and WsConnection factory classes. - 'use strict' directive. - Documentation in russian. - Secure HTTP protocol is now supported. - CHANGELOG.md. - Introspection getErrors method. - Function registerError for adding new error types for api. ### Changed - Function getIntrospectionModule return object with 'introspection' property. - Class ConsoleTransport not a singlton. - HTTPConnection fix bug when global HEADERS object was modifing.
- Loading branch information
Showing
16 changed files
with
6,163 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.vscode | ||
node_modules | ||
pgdata | ||
certs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
<!-- ## [Unreleased] --> | ||
|
||
## [2.0.0] - 2022-08-20 | ||
|
||
### Added | ||
|
||
- Server 'start' method. | ||
- Default config to server module. | ||
- HttpConnection and WsConnection factory classes. | ||
- 'use strict' directive. | ||
- Documentation in russian. | ||
- Secure HTTP protocol is now supported. | ||
- CHANGELOG.md. | ||
- Introspection getErrors method. | ||
- Function registerError for adding new error types for api. | ||
|
||
### Changed | ||
|
||
- Function getIntrospectionModule return object with 'introspection' property. | ||
- Class ConsoleTransport not a singlton. | ||
- HTTPConnection fix bug when global HEADERS object was modifing. | ||
|
||
## [1.0.2] - 2022-03-14 | ||
|
||
### Added | ||
|
||
- Unit tests. | ||
|
||
### Changed | ||
|
||
- Fix bug when reading property of undefined in client.checkConnection. | ||
|
||
## [1.0.1] - 2022-03-11 | ||
|
||
### Changed | ||
|
||
- Descriptions for Auth module schema. | ||
|
||
## [1.0.0] - 2022-03-11 | ||
|
||
### Added | ||
|
||
- Initial project structure. | ||
- User module. | ||
- Session module. | ||
- Security utils. | ||
- Auth module. | ||
- Database module. | ||
- Server module. | ||
- Validator service. | ||
- HTTP and WebSocket transport. | ||
- Logger service. | ||
- Introspection module. | ||
|
||
[unreleased]: https://github.com/web-soft-llc/web-soft-server/compare/v2.0.0...master | ||
[2.0.0]: https://github.com/web-soft-llc/web-soft-server/compare/v.1.0.2...v2.0.0 | ||
[1.0.2]: https://github.com/web-soft-llc/web-soft-server/compare/v.1.0.1...v.1.0.2 | ||
[1.0.1]: https://github.com/web-soft-llc/web-soft-server/compare/v.1.0.0...v.1.0.1 | ||
[1.0.0]: https://github.com/web-soft-llc/web-soft-server/releases/tag/v.1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# web-soft-server | ||
# Server for web-soft projects. | ||
|
||
Server for web-soft-projects. | ||
[Документация на русском языке.](lang/README-RU.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
|
||
export function registerError(label: string, code: number, message?: string): { code: number; message: string }; | ||
|
||
export interface ServerConfig { | ||
port?: number; | ||
host?: string; | ||
cors?: boolean; | ||
serverCloseTimeout?: number; | ||
} | ||
|
||
export interface MethodDataSchema { | ||
type: string; | ||
description?: string; | ||
required?: Array<string>; | ||
properties?: { [property: string]: MethodDataSchema }; | ||
items?: MethodDataSchema; | ||
additionalProperties?: boolean; | ||
} | ||
|
||
export interface MethodSchema { | ||
public?: boolean; | ||
description?: string; | ||
params?: MethodDataSchema; | ||
result?: MethodDataSchema; | ||
emit?: MethodDataSchema; | ||
roles?: Array<string>; | ||
transport?: 'http' | 'ws'; | ||
} | ||
|
||
export interface ServerModule { | ||
schema: { [method: string]: MethodSchema }; | ||
Module: Class<T>; | ||
} | ||
|
||
export interface User { | ||
username: string; | ||
password: string; | ||
role: string; | ||
createdTime: string; | ||
} | ||
|
||
export interface UserRole { | ||
role: string; | ||
createdTime: string; | ||
} | ||
|
||
export interface Session { | ||
username: string; | ||
token: string; | ||
createdTime: string; | ||
} | ||
|
||
export interface LoggerSettings { | ||
info: boolean; | ||
debug: boolean; | ||
warn: boolean; | ||
error: boolean; | ||
fatal: boolean; | ||
sql: boolean; | ||
} | ||
|
||
export interface LoggerMessage { | ||
type: string; | ||
message: string; | ||
stack?: string; | ||
} | ||
|
||
export interface LoggerTransport { | ||
log: (data: LoggerMessage) => void; | ||
} | ||
|
||
export interface ErrorMetaData { | ||
code: number; | ||
message: string; | ||
internal: string; | ||
} | ||
|
||
export interface DatabaseData { | ||
[key: string]: number | string | boolean; | ||
} | ||
|
||
export class Server { | ||
constructor(config?: ServerConfig); | ||
start(modules: { [name: string]: ServerModule }): void; | ||
close(): void; | ||
} | ||
|
||
export class ConnectionError extends Error { | ||
constructor(meta: ErrorMetaData, data: any); | ||
code?: number; | ||
data?: any; | ||
internal?: string; | ||
pass: boolean; | ||
} | ||
|
||
export declare namespace validator { | ||
function compile(schema: MethodDataSchema): (data: any) => boolean; | ||
} | ||
|
||
export declare namespace userService { | ||
function save(username: string, hashPassword: string): Promise<UserRole>; | ||
function getByUsername(username: string): Promise<User>; | ||
function updatePassword(username: string, password: string): Promise<UserRole>; | ||
} | ||
|
||
export declare namespace sessionService { | ||
function restoreSession(request: IncomingMessage): Promise<Session>; | ||
function startSession(request: IncomingMessage, response: ServerResponse, username: string): Promise<Session>; | ||
function endSession(request: IncomingMessage, response: ServerResponse): Promise<Session>; | ||
} | ||
|
||
export declare namespace logger { | ||
function setSettings(settings: LoggerSettings): void; | ||
function setTransport(transport: LoggerTransport): void; | ||
function info(...data: any[]): void; | ||
function debug(...data: any[]): void; | ||
function warn(...data: any[]): void; | ||
function sql(...data: any[]): void; | ||
function error(error: Error): void; | ||
function fatal(error: Error): void; | ||
} | ||
|
||
export declare namespace database { | ||
function query(text: string, params: Array<any>): Promise<any[]>; | ||
function insert(table: string, data: DatabaseData, returning: Array<string>): Promise<any>; | ||
function select( | ||
table: string, | ||
fields: Array<string>, | ||
conditions: DatabaseData, | ||
orderFields: Array<string>, | ||
itemsOnPage: number, | ||
page: number | ||
): Promise<any[]>; | ||
function update( | ||
table: string, | ||
delta: DatabaseData, | ||
conditions: DatabaseData, | ||
returning: Array<string> | ||
): Promise<any[]>; | ||
function _delete(table: string, conditions: DatabaseData, returning: Array<string>): Promise<any[]>; | ||
export { _delete as delete, query, insert, select, update }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.