Skip to content

Commit

Permalink
Implemented: write docs for utils #89
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Apr 11, 2024
1 parent 8327611 commit e3e6f84
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ outline: deep
* Implemented: add warning when someone generates web or rest without a record #91
* Implemented: user id in statistics and add clipboard copy #88
* Fixed: documentation for Related Records is broken #86
* Implemented: write docs for utils #89

## 2024-04-10
* Implemented: filterQualifier: true should be in the examples for all relation ids #96
Expand Down
55 changes: 54 additions & 1 deletion docs/subsystems/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,57 @@
outline: deep
---

gotta write this
# Utilities

There are a bunch of utilities libraries in `ving/utils` that solve common problems you may have when writing server side code. Each of them has JSDoc for the actual functional definitions, but we want to call attention tot he different utilites libraries here so you know they exist.

## Utility Libraries

### findObject

Provides light wrappers around the javascript `find()` function that throws an error if the object you're looking for isn't found.

### fs

A bunch of wrappers around node's `fs` library to give you easy to use and terse filesystem functions for checking if a file/folder exists, or reading/writing JSON files, or sanitizing filenames, and more.

### miniHash

Provides a function to give something similar to an MD5 hash, or a SHA1 hash, but returns a shorter string (around 8 characters). This is very useful when you need to be able to disambiguate files or other content, but you also need the resulting string to be shorter than a normal file hash. Note that because it's shorter there is a greater chance of collision, but if you know the risks you can work around them.

### ouch

A way to throw standardized errors through-out ving.

### rest

A bunch of utilities that provide glue between Nuxt's rest system and Ving's records.

### sleep

A function for waiting for a few seconds or minutes.

## Honorable Mentions

There are a bunch of other places in the codebase that have utility functions you might end up using all over, that just aren't located in the `ving/utils` folder.

### ving/index.mjs

Combines a bunch of commonly used ving utilities into a single roll up package.

### ving/drizzle/orm.mjs

Exports all of the useful functions from drizzle that are normally spread out across many different libraries.

### ving/record/VingRecord.mjs

Exports a `useKind()` function that allows you to dynamically instanciate any VingKind.

### ving/schema/helpers.mjs

Has utility functions for defining schemas.

### ving/schema/map.mjs

Has functions for finding a ving schema based upon some criteria.

0 comments on commit e3e6f84

Please sign in to comment.