# @xdn/core

> Core library for the [Moovweb XDN](https://developer.moovweb.com), infrastructure to run your big, dynamic website frontend and make it load in less than one second.

Latest version **2.53.6** (published 2022-01-11) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @xdn/core
pnpm add @xdn/core
yarn add @xdn/core
bun add @xdn/core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.53.6 |
| Published | 2022-01-11 |
| First published | 2020-03-23 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 29 |
| Unpacked size | 660.9 KB |
| Known vulnerabilities | 0 (+4 in 4 direct dependencies) |
| Install scripts | no |
| Maintainers | moovweb-admin |

## Links

- npm: https://www.npmjs.com/package/@xdn/core
- npm.io page: https://npm.io/package/@xdn/core

## Dependencies (29)

- [ajv](https://npm.io/package/ajv.md) ^6.12.6
- [pino](https://npm.io/package/pino.md) ^6.11.2
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [slash](https://npm.io/package/slash.md) ^3.0.0
- [cookie](https://npm.io/package/cookie.md) ^0.4.1
- [globby](https://npm.io/package/globby.md) ^11.0.2
- [express](https://npm.io/package/express.md) ^4.17.1
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.4
- [webpack](https://npm.io/package/webpack.md) ^5.26.3
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [lru-cache](https://npm.io/package/lru-cache.md) ^6.0.0
- [ts-loader](https://npm.io/package/ts-loader.md) ^8.0.18
- [cls-hooked](https://npm.io/package/cls-hooked.md) ^4.2.2
- [http-proxy](https://npm.io/package/http-proxy.md) ^1.18.1
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.29
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.2
- [content-type](https://npm.io/package/content-type.md) ^1.0.4
- [tcp-port-used](https://npm.io/package/tcp-port-used.md) ^1.0.2
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^6.2.0
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0
- [decode-uri-component](https://npm.io/package/decode-uri-component.md) ^0.2.0
- [resolve-package-path](https://npm.io/package/resolve-package-path.md) ^2.0.0
- [webpack-dev-middleware](https://npm.io/package/webpack-dev-middleware.md) ^4.1.0
- [@types/lodash.clonedeep](https://npm.io/package/@types/lodash.clonedeep.md) ^4.5.6
- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) ^3.9.0

## Recent versions

- 2.53.6 (latest) — 2022-01-11
- 2.53.6-next-1641895591-f1d5f1649.0 (next) — 2022-01-11
- 2.53.5-next-1641201537-c1cdb4568.0 (next-v2) — 2022-01-03
- 1.48.2 (latest-v1) — 2020-10-27
- 2.53.7-next-1641895574-4891585a6.0 — 2022-01-11
- 2.53.7-next-1641893132-22be18a83.0 — 2022-01-11
- 2.53.6-next-1641892929-f436f56da.0 — 2022-01-11
- 2.53.6-next-1641398325-01bf686c4.0 — 2022-01-05
- 2.53.5 — 2022-01-05
- 2.53.5-next-1641219106-ff2936ac0.0 — 2022-01-03
- 2.53.5-next-1641210071-2f979ef07.0 — 2022-01-03
- 2.53.5-next-1641201434-873aac607.0 — 2022-01-03
- 2.53.5-next-1641060563-3bc9c3b88.0 — 2022-01-01
- 2.53.4 — 2022-01-01
- 2.53.5-next-1640891080-513b105dc.0 — 2021-12-30
- … 3275 more at https://npm.io/package/@xdn/core/versions

## README

## Overview

Core library for the [Moovweb XDN](https://developer.moovweb.com), infrastructure to run your big, dynamic website frontend and make it load in less than one second.

The `@xdn/core` package provides a CDN-as-JavaScript API for defining edge routing and logic on the XDN.


## Example Routes File

```js
// routes.js

import { Router } from '@xdn/core/router'
import { createNextPlugin } = from '@xdn/next'
import { renderNextPage, nextRoutes } from '@xdn/next'

export default new Router()
  // redirect at edge
  .match('/some/path/:withVar', async ({ redirect }) => {
    redirect('/some/other/path/:withVar', { statusCode: 301 })
  })

  // proxy the legacy site
  .match('/some/path/:withVar', async ({ proxy }) => {
    proxy('legacy', {
      path: '/some/other/path/:withVar',
    })
  })

  // match based on header and proxy the legacy site
  .match({ headers: { 'xdn-device-type': /desktop/ } }, async ({ proxy }) => {
    proxy('legacy')
  })

  // vanity URL for next.js
  .match('/some/vanity/url/:productId', res => {
    renderNextPage('/p/[productId]', res)
  })

  // Send a synthetic html response
  .match('/static-html', ({ setResponseHeader, send }) => {
    setResponseHeader('Content-Type', 'text/html; charset=UTF-8')
    send('<html><body><h1>Hello world!</h1></body></html>', 200)
  })

  // match Next.js routes based on the pages directory
  .use(nextRoutes)

  // fall back to proxying the legacy site
  .fallback(({ proxy }) => proxy('legacy'))
```

---
_Source: https://npm.io/package/@xdn/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
