Skip to content

createShorty(config) ​

The entry point. Returns routers and a model; never an app, never a server.

js
import { createShorty } from '@jeffjassky/shorty';

const pkg = createShorty({ connection: mongoose, resolveUser });

Config ​

See Configuration for the full table and the reasoning.

Returns ​

modelThe Mongoose model. await model.createIndexes() once at boot.
routesPublic JSON router — Routers
adminRoutesAdmin JSON router. You guard it.
ui(opts)Public SPA router — UI routers
adminUi(opts)Admin SPA router
purgeUser(id)Outbound adapter direction — Account deletion

Also exported ​

createUserAdapter(opts)Object form of the user adapter
defaultResolveUser(req)The built-in inbound adapter
createLinkModel(opts)Model factory
buildLinkSchema(opts)The bare schema, uncompiled
defaultSpaDir()Resolved path to the shipped SPA bundle
HttpErrorstatus + stable code, answered as itself rather than a 500

Throws ​

  • Both userAdapter and resolveUser passed — it will not silently pick one
  • resolveUser is not a function
  • track is not a function

Released under the MIT License.