Skip to content

Commit

Permalink
docs: predominantly showcase TypeScript instead of shield()
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Nov 9, 2022
1 parent 65aac4a commit 142067b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions docs/pages/abort-vs-error.page.server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ function getUser({ permission }) {
> Such `getContext()` wrapper is a common Telefunc technique explained at <Link href="/permissions#getcontext-wrapping" doNotInferSectionTitle={true} />.
```js
// components/Comment.telefunc.js
// components/Comment.telefunc.ts
// Environment: Node.js

import { getUser } from '../auth/getUser'
import { shield } from 'telefunc'

shield(onCommentDelete, [shield.type.number])
export async function onCommentDelete(id) {
export async function onCommentDelete(id: number) {
// Only admins are allowed to delete a comment
const user = getUser({ permission: 'admin' })
const comment = await Comment.findOne({ id })
Expand Down
7 changes: 2 additions & 5 deletions docs/pages/ssr-context.page.server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { Link } from '@brillout/docpress'
We usually call telefunctions remotely from the browser:

```js
// CreateTodo.telefunc.js
// CreateTodo.telefunc.ts
// Environment: Node.js server

import { shield } from 'telefunc'

shield(onNewTodo, [shield.type.string])
export async function onNewTodo(text) {
export async function onNewTodo(text: string) {
const todoItem = new Todo({ text })
await todoItem.save()
}
Expand Down

0 comments on commit 142067b

Please sign in to comment.