@hapipal/haute-couture

中文文档
4.3.1发布于 2022/12/05MITCommonJS近 30 天下载 8724

File-based hapi plugin composer

原始使用文档
文档目录4 节
  1. Installation
  2. Introduction
  3. Usage
  4. Example

haute-couture

File-based hapi plugin composer

Build Status Coverage Status

Lead Maintainer - Devin Ivy

Installation

npm install @hapipal/haute-couture

Introduction

This library will wire your hapi plugin together based simply upon where you place files and the contents of those files. It has the ability to call nearly every configuration-related method in the hapi plugin API. This means many good things! Here are a few:

  • Route configurations placed in your routes/ directory will be registered using server.route().
  • You can place your authentication scheme in auth/schemes.js rather than calling server.auth.scheme().
  • You can provision a cache simply by placing its configuration in caches/my-cache-name.js, and forget about server.cache.provision().
  • You can still write all the custom plugin code you desire.
  • You can customize many aspects regarding how haute-couture composes your hapi plugin from files.

Haute-couture understands 19 hapi plugin methods: those for server methods, server/request decorations, request lifecycle extensions, route configuration, cookie definitions, vision view managers, schwifty models, schmervice services, and plenty more. And if that's not enough, you can always teach it about more through its flexible amendment system.

Usage

See also the API Reference

Haute-couture is intended for use with hapi v19+ and nodejs v12+, in addition to several optional peer hapi plugins noted in package.json (see v3 for lower support).

This library is not a hapi plugin: think of it instead as a useful subroutine of any hapi plugin. The full documentation of the files and directories it recognizes can be found in the API documentation.

Example

Here's an example of a very simple plugin that registers a single "pinger" route.

index.js

const HauteCouture = require('@hapipal/haute-couture');

module.exports = {
  name: 'my-hapi-plugin',
  register: async (server, options) => {

    // Custom plugin code can go here

    await HauteCouture.compose(server, options);
  }
};

routes/pinger.js

module.exports = {
  method: 'get',
  path: '/',
  options: {
    handler(request) {

      return { ping: 'pong' };
    }
  }
};

版本与发布记录

@hapipal/haute-couture 共发布 7 个版本,首次发布于 2020/12/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.3.1latest2022/12/053 年前
4.3.02022/11/283 年前
4.3.0-types.0types2022/03/224 年前
4.2.02021/12/084 年前
4.1.02021/04/065 年前
4.0.12021/02/175 年前

关于 @hapipal/haute-couture 的常见问题

@hapipal/haute-couture 是什么?

File-based hapi plugin composer

如何安装 @hapipal/haute-couture?

在项目目录运行 npm install @hapipal/haute-couture,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@hapi/hapi(>=19 <22)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@hapipal/haute-couture 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/hapipal__haute-couture 是否存在。

@hapipal/haute-couture 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@hapipal/haute-couture 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@hapipal/haute-couture 可以商用吗?

@hapipal/haute-couture 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@hapipal/haute-couture 的下载量有多少?

根据 npm 官方下载统计,@hapipal/haute-couture 在 2026/10/17 – 2026/11/15 这 30 天内被下载 8,724 次,日均约 291 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@hapipal/haute-couture 还在维护吗?

最新版本 4.3.1 发布于 2022/12/05(3 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/12/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。