Skip to content

Commit

Permalink
fix: docs and date exports
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Dec 22, 2024
1 parent 3564c34 commit cb492fe
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 30 deletions.
3 changes: 3 additions & 0 deletions check-required-env/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
},
"imports": {
"@frytg/logger": "jsr:@frytg/[email protected]"
},
"publish": {
"exclude": ["*.test.ts"]
}
}
3 changes: 2 additions & 1 deletion crypto/generate-default-keys.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* @module
* Run key generation for default key sizes and print the results to the console
*
* @example
* ```bash
* deno run jsr:@frytg/crypto/generate-default-keys
* ```
*
* @module
*/

// load module
Expand Down
4 changes: 2 additions & 2 deletions crypto/generate-key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// deno-lint-ignore-file no-console
/**
* @module
*
* This module provides a function to generate a key of the specified number of bytes and print the key in base64 and hex to the console or return the key as a Buffer.
*
* @example
Expand All @@ -10,6 +8,8 @@
*
* generateKey(32, true)
* ```
*
* @module
*/

// load packages
Expand Down
5 changes: 3 additions & 2 deletions crypto/hash.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* @module
* {@linkcode hashSha256 | SHA-256} and {@linkcode hashSha512 | SHA-512} hash functions
*
* @example
* @example Hash SHA-256
* ```ts
* import { hashSha512 } from '@frytg/crypto/hash'
*
* hashSha512('hello world')
* ```
*
* @module
*/

// load packages
Expand Down
5 changes: 3 additions & 2 deletions crypto/hmac.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* @module
* {@linkcode hmacSha256 | HMAC SHA-256} and {@linkcode hmacSha512 | HMAC SHA-512} hash functions
*
* @example
* @example HMAC SHA-512
* ```ts
* import { hmacSha512 } from '@frytg/crypto/hmac'
*
* hmacSha512('hello world', '0123456789abcdef')
* ```
*
* @module
*/

// load packages
Expand Down
6 changes: 6 additions & 0 deletions dates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

This is a simple opinionated wrapper around the [Luxon](https://github.com/moment/luxon) library to provide pre-configured helpers.

```ts
import { getISO } from '@frytg/dates';

getISO(); // returns string like 2025-01-01T00:00:00.000Z
```

## Author

Created by [@frytg](https://github.com/frytg) / [frytg.digital](https://www.frytg.digital)
Expand Down
42 changes: 25 additions & 17 deletions dates/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ const LOCAL_TIMEZONE = 'Europe/Amsterdam'
const DATE_HOUR_MINUTES_FORMAT = 'ccc, d. LLLL yyyy - h:mma'

/**
* Luxon DateTime
* Export DateTime from Luxon
* @returns {DateTime} DateTime
*
* @example
* ```ts
* import { DateTime } from '@frytg/dates'
*
* DateTime.fromMillis(1719859200000)
* ```
*/
export { DateTime }

Expand All @@ -17,7 +25,7 @@ export { DateTime }
*
* @example
* ```ts
* import { toLocal } from 'jsr:@frytg/dates'
* import { toLocal } from '@frytg/dates'
*
* toLocal(getNow())
* ```
Expand All @@ -31,7 +39,7 @@ export const toLocal = (date: DateTime): DateTime => date.setZone(LOCAL_TIMEZONE
*
* @example
* ```ts
* import { msToUnix } from 'jsr:@frytg/dates'
* import { msToUnix } from '@frytg/dates'
*
* msToUnix(getMs())
* ```
Expand All @@ -44,21 +52,21 @@ export const msToUnix = (ms: number): number => Number.parseInt(`${ms / 1000}`)
*
* @example
* ```ts
* import { getNow } from 'jsr:@frytg/dates'
* import { getNow } from '@frytg/dates'
*
* getNow()
* ```
*/
export const getNow = (): DateTime => DateTime.now()

/**
* Provides util to get .unix() style value
* Get unix timestamp
* @param {DateTime} [date] - date object
* @returns {number} unix timestamp
*
* @example
* ```ts
* import { getUnix } from 'jsr:@frytg/dates'
* import { getUnix } from '@frytg/dates'
*
* getUnix()
* getUnix(getNow())
Expand All @@ -67,13 +75,13 @@ export const getNow = (): DateTime => DateTime.now()
export const getUnix = (date?: DateTime): number => msToUnix((date || getNow()).valueOf())

/**
* Provides util to get ms timestamp
* Get ms (milliseconds) timestamp
* @param {DateTime} [date] - date object
* @returns {number} ms timestamp
*
* @example
* ```ts
* import { getMs } from 'jsr:@frytg/dates'
* import { getMs } from '@frytg/dates'
*
* getMs()
* getMs(getNow())
Expand All @@ -82,13 +90,13 @@ export const getUnix = (date?: DateTime): number => msToUnix((date || getNow()).
export const getMs = (date?: DateTime): number => (date || getNow()).valueOf()

/**
* Provides util to get ISO string in UTC timezone
* Get ISO string in UTC timezone
* @param {DateTime} [date] - date object
* @returns {string} ISO string
*
* @example
* ```ts
* import { getISO } from 'jsr:@frytg/dates'
* import { getISO } from '@frytg/dates'
*
* getISO()
* getISO(getNow())
Expand All @@ -110,7 +118,7 @@ export const getIso = getISO
*
* @example
* ```ts
* import { getMsOffset } from 'jsr:@frytg/dates'
* import { getMsOffset } from '@frytg/dates'
*
* getMsOffset(getMs())
* ```
Expand All @@ -125,7 +133,7 @@ export const getMsOffset = (ms: number): number => getMs() - ms
*
* @example
* ```ts
* import { getRelative } from 'jsr:@frytg/dates'
* import { getRelative } from '@frytg/dates'
*
* getRelative(getNow())
* getRelative(getNow(), 'nl-NL')
Expand All @@ -141,7 +149,7 @@ export const getRelative = (date: DateTime, locale = 'en-US'): string => date.to
*
* @example
* ```ts
* import { getYearMonthDay } from 'jsr:@frytg/dates'
* import { getYearMonthDay } from '@frytg/dates'
*
* getYearMonthDay(getNow()) // YYYYMMDD
* getYearMonthDay(getNow(), true) // YYYY-MM-DD
Expand All @@ -157,7 +165,7 @@ export const getYearMonthDay = (date?: DateTime, withDashes = false): string | n
*
* @example
* ```ts
* import { parseISO } from 'jsr:@frytg/dates'
* import { parseISO } from '@frytg/dates'
*
* parseISO(getISO())
* parseISO('2024-11-23T10:00:00.000Z')
Expand All @@ -179,7 +187,7 @@ export const parseIso = parseISO
*
* @example
* ```ts
* import { getDateHourMinutes } from 'jsr:@frytg/dates'
* import { getDateHourMinutes } from '@frytg/dates'
*
* getDateHourMinutes(getNow())
* ```
Expand All @@ -194,7 +202,7 @@ export const getDateHourMinutes = (date: DateTime): string =>
*
* @example
* ```ts
* import { getFullRelativeTime } from 'jsr:@frytg/dates'
* import { getFullRelativeTime } from '@frytg/dates'
*
* getFullRelativeTime(getNow())
* ```
Expand All @@ -209,7 +217,7 @@ export const getFullRelativeTime = (date: DateTime): string => `${getDateHourMin
*
* @example
* ```ts
* import { formatDuration } from 'jsr:@frytg/dates'
* import { formatDuration } from '@frytg/dates'
*
* formatDuration(1000) // 1s
*
Expand Down
2 changes: 1 addition & 1 deletion dates/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@frytg/dates",
"version": "0.1.0",
"version": "0.1.1",
"exports": "./dates.ts",
"imports": {
"@std/fmt": "jsr:@std/fmt@^1.0.3",
Expand Down
3 changes: 3 additions & 0 deletions logger/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"exports": "./logger.ts",
"imports": {
"winston": "npm:winston@^3.17.0"
},
"publish": {
"exclude": ["*.test.ts"]
}
}
3 changes: 2 additions & 1 deletion logger/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @module
* A pre-configured logger that is ready to use with syslog levels.
*
* @module
*/

// load packages
Expand Down
9 changes: 7 additions & 2 deletions storage-s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { getObject } from '@frytg/storage-s3';
const object = await getObject('path/to/object.json', { parseJson: true });
```

The MinIO client will be initialized with the required environment variables `STORE_S3_ENDPOINT`, `STORE_S3_ACCESS_KEY`, and `STORE_S3_SECRET_KEY`.
The MinIO client will be initialized with these required environment variables:

- `STORE_S3_ENDPOINT`
- `STORE_S3_ACCESS_KEY`
- `STORE_S3_SECRET_KEY`

## Methods

Expand All @@ -22,7 +26,8 @@ The MinIO client will be initialized with the required environment variables `ST
- [objectExists](https://jsr.io/@frytg/storage-s3/doc/~/objectExists)
- [listObjects](https://jsr.io/@frytg/storage-s3/doc/~/listObjects)

Also see all options in the [MinIO API documentation](https://min.io/docs/minio/linux/developers/javascript/API.html). They can be used by importing the `Client` object.
Also see all options in the [MinIO API documentation](https://min.io/docs/minio/linux/developers/javascript/API.html).
They can be used by importing the `Client` object.

## Author

Expand Down
3 changes: 3 additions & 0 deletions storage-s3/deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"exports": "./storage.ts",
"imports": {
"minio": "npm:minio@^8.0.2"
},
"publish": {
"exclude": ["*.test.ts"]
}
}
2 changes: 0 additions & 2 deletions storage-s3/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* Storage module for S3 with common operations using MinIO.
*
* @module
*
* @see https://min.io/docs/minio/linux/developers/javascript/API.html
*/

// import packages
Expand Down

0 comments on commit cb492fe

Please sign in to comment.