Skip to main content

farrow-deno-api

A deno server middleware.

Install#

npm install farrow-deno-api
yarn add farrow-deno-api

First Look#

// server
import { Http } from 'farrow-http'
import { DenoService } from from 'farrow-deno-api'
// api definition
...
const entries = {
getCount,
setCount,
triggerError,
}
const CounterService = DenoService({
entries,
})
const http = Http()
const server = http.server()
http.route('/counter').use(CounterService)
http.listen(3000)
// client
import { api } from 'http://localhost:3000/counter/client.ts'
api.getCount({}).then(console.log)

Options#

entries#

entries: ApiEntries

ApiEntries

namespace#

namespace: string = 'client'

it affect the path of file:

import { api } from 'http://localhost:3000/counter/client.ts'

in client.

codegen#

codegen?: CodegenOptions

CodegenOptions

transform#

transform?: (source: string) => string

transform

format#

format?: (source: string) => string

format