Skip to content

Commit

Permalink
docs: fix JSDoc formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorikairox committed Oct 2, 2024
1 parent 55dcb89 commit b7b032c
Show file tree
Hide file tree
Showing 36 changed files with 456 additions and 386 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
deno-version: canary

- name: Publish package
run: deno publish
run: deno publish
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

## Warning

From version 2.4.0, Danet is only available via [JSR](https://jsr.io/) at [@danet/core](https://jsr.io/@danet/core). It's a step closer to runtime agnosticism.
From version 2.4.0, Danet is only available via [JSR](https://jsr.io/) at
[@danet/core](https://jsr.io/@danet/core). It's a step closer to runtime
agnosticism.

## Description

Expand Down Expand Up @@ -52,8 +54,8 @@ bug on our [Github Repository](https://github.com/Savory/Danet) and
## Installation

```sh
deno install --global -A -n danet jsr:@danet/cli
danet new <my-project>
deno install --global -A -n danet jsr:@danet/cli
danet new <my-project>
```

## Documentation
Expand All @@ -64,7 +66,6 @@ bug on our [Github Repository](https://github.com/Savory/Danet) and

[Read our blog](https://savory.github.io/)


## Contributing

- Contributions make the open-source community such an amazing place to learn,
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"./validation": "./validation.ts",
"./hook": "./src/hook/mod.ts",
"./logger": "./src/logger.ts"
},
},
"lint": {
"include": [
"src/"
Expand Down
9 changes: 7 additions & 2 deletions spec/queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
Module,
OnQueueMessage,
} from '../mod.ts';
import { assertEquals, assertSpyCall, spy, assertSpyCalls } from '../src/deps_test.ts';
import {
assertEquals,
assertSpyCall,
assertSpyCalls,
spy,
} from '../src/deps_test.ts';

const sleep = (msec: number) =>
new Promise((resolve) => setTimeout(resolve, msec));
Expand Down Expand Up @@ -64,7 +69,7 @@ Deno.test('Queue Module', async (t) => {
assertEquals(await res.text(), 'OK');

await sleep(500);
assertSpyCalls(callback, 1)
assertSpyCalls(callback, 1);
assertSpyCall(callback, 0, {
args: [payload],
});
Expand Down
72 changes: 35 additions & 37 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,39 @@
* @example
* ```typescript
* import {
* Controller,
* DanetApplication,
* Get,
* Module,
* Query,
* } from '../src/mod.ts';
* Controller,
* DanetApplication,
* Get,
* Module,
* Query,
* } from '../src/mod.ts';
*
* @Controller('')
* class FirstController {
* constructor() {
* }
*
* @Controller('')
* class FirstController {
* constructor() {
* }
* @Get('hello-world/:name')
* getHelloWorld(
* @Param('name') name: string,
* ) {
* return `Hello World ${name}`;
* }
* }
*
* @Module({
* controllers: [FirstController]
* })
* class FirstModule {}
*
* @Get('hello-world/:name')
* getHelloWorld(
* @Param('name') name: string,
* ) {
* return `Hello World ${name}`;
* }
* }
* const app = new DanetApplication();
* await app.init(FirstModule);
*
* @Module({
* controllers: [FirstController]
* })
* class FirstModule {}
*
* const app = new DanetApplication();
* await app.init(FirstModule);
*
* let port = Number(Deno.env.get('PORT'));
* if (isNaN(port)) {
* port = 3000;
* }
* app.listen(port);
* let port = Number(Deno.env.get('PORT'));
* if (isNaN(port)) {
* port = 3000;
* }
* app.listen(port);
* ```
*/

Expand Down Expand Up @@ -188,7 +186,7 @@ export class DanetApplication {

/**
* Initializes the application with the provided module.
*
*
* @param Module - The constructor of the module to initialize.
* @returns A promise that resolves when the initialization process is complete.
*/
Expand All @@ -202,7 +200,7 @@ export class DanetApplication {

/**
* Closes the application by executing the necessary hooks and shutting down the internal HTTP server.
*
*
* @async
* @returns {Promise<void>} A promise that resolves when the application has been closed.
*/
Expand All @@ -214,18 +212,18 @@ export class DanetApplication {

/**
* Starts the HTTP server and begins listening on the specified port.
*
*
* @param {number} [port=3000] - The port number on which the server will listen.
* @returns {Promise<{ port: number }>} A promise that resolves with an object containing the port number.
*
*
* @remarks
* This method initializes an `AbortController` to manage the server's lifecycle and uses Deno's `serve` function to start the server.
* The server will log a message indicating the port it is listening on.
*
*
* @example
* ```typescript
* const app = new DanetApplication();
* await app.init(FirstModule);
* await app.init(FirstModule);
* const { port } = app.listen(3000);
* ```
*/
Expand All @@ -247,7 +245,7 @@ export class DanetApplication {

/**
* Get hono application instance.
*
*
* @returns {Application} The hono instance.
*/
get router(): Application {
Expand Down
13 changes: 7 additions & 6 deletions src/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ import { Logger } from '../mod.ts';
type Listener<P = any> = (payload: P) => void;

/**
* @class EventEmitter
* @description A class that provides a simple event-driven architecture for subscribing, emitting, and unsubscribing events.
*
* Provides event-driven architecture for subscribing, emitting, and unsubscribing events.
*
* @example
* ```ts
* const emitter = new EventEmitter();
*
*
* // Subscribe to an event
* emitter.subscribe('eventName', (payload) => {
* console.log(payload);
* });
*
*
* // Emit an event
* emitter.emit('eventName', { key: 'value' });
*
*
* // Unsubscribe from an event
* emitter.unsubscribe('eventName');
* ```
*/
export class EventEmitter {
private logger: Logger = new Logger('EventEmitter');
Expand Down
4 changes: 2 additions & 2 deletions src/exception/filter/decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const filterCatchTypeMetadataKey = 'errorCaught';
* @returns A metadata function that sets the metadata for the error type to catch.
*/
export function Catch(ErrorType: Constructor): MetadataFunction {
return SetMetadata(filterCatchTypeMetadataKey, ErrorType);
}
return SetMetadata(filterCatchTypeMetadataKey, ErrorType);
}
6 changes: 2 additions & 4 deletions src/exception/filter/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { Injector } from '../../injector/injector.ts';
import { WebSocketPayload } from '../../router/websocket/payload.ts';

/**
* @class FilterExecutor
* @description
* The `FilterExecutor` class is responsible for executing exception filters
* Responsible for executing exception filters
* based on metadata and handling errors within the context of an HTTP request.
* It utilizes an injector to manage dependencies and retrieve filter instances.
* It utilizes the injector to manage dependencies and retrieve filter instances.
*
* @constructor
* @param {Injector} injector - The dependency injector used to manage and retrieve filter instances.
Expand Down
4 changes: 2 additions & 2 deletions src/exception/filter/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { HttpContext } from '../../router/router.ts';

/**
* Interface representing an exception filter.
*
*
* This interface defines a method to handle exceptions that occur within an HTTP context.
* Implementations of this interface can provide custom logic for handling different types of exceptions.
*
*
* @interface ExceptionFilter
*/
export interface ExceptionFilter {
Expand Down
Loading

0 comments on commit b7b032c

Please sign in to comment.