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
model | The Mongoose model. await model.createIndexes() once at boot. |
routes | Public JSON router — Routers |
adminRoutes | Admin 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 |
HttpError | status + stable code, answered as itself rather than a 500 |
Throws
- Both
userAdapterandresolveUserpassed — it will not silently pick one resolveUseris not a functiontrackis not a function