Harper provides extended features using built-in components. They do not need to be installed with a package manager, and simply must be specified in a config to run. These are used throughout many Harper docs, guides, and examples. Unlike external components which have their own semantic versions, built-in components follow Harper's semantic version.
Specify custom endpoints using Fastify.
This component is a Resource Extension and can be configured with the files
and urlPath
configuration options.
Complete documentation for this feature is available here: Define Fastify Routes
fastifyRoutes:
files: 'routes/*.js'
GraphQL querying is experimental, and only partially implements the GraphQL Over HTTP / GraphQL specifications.
Enables GraphQL querying via a /graphql
endpoint loosely implementing the GraphQL Over HTTP specification.
Complete documentation for this feature is available here: GraphQL
graphql: true
Specify schemas for Harper tables and resources via GraphQL schema syntax.
This component is a Resource Extension and can be configured with the files
and urlPath
configuration options.
Complete documentation for this feature is available here: Defining Schemas
graphqlSchema:
files: 'schemas.graphql'
Specify custom, JavaScript based Harper resources.
Refer to the Application Custom Functionality with JavaScript guide, or Resource Class reference documentation for more information on custom resources.
This component is a Resource Extension and can be configured with the files
and urlPath
configuration options.
jsResource:
files: 'resource.js'
Load environment variables via files like .env
.
This component is a Resource Extension and can be configured with the files
and urlPath
configuration options.
Ensure this component is specified first in config.yaml
so that environment variables are loaded prior to loading any other components.
loadEnv:
files: '.env'
This component matches the default behavior of dotenv where existing variables take precedence. Specify the override
option in order to override existing environment variables assigned to process.env
:
loadEnv:
files: '.env'
override: true
Important: Harper is a single process application. Environment variables are loaded onto
process.env
and will be shared throughout all Harper components. This means environment variables loaded by one component will be available on other components (as long as the components are loaded in the correct order).
Enable automatic REST endpoint generation for exported resources with this component.
Complete documentation for this feature is available here: REST
rest: true
This component contains additional options:
To enable Last-Modified
header support:
rest:
lastModified: true
To disable automatic WebSocket support:
rest:
webSocket: false
Specify roles for Harper tables and resources.
This component is a Resource Extension and can be configured with the files
and urlPath
configuration options.
Complete documentation for this feature is available here: Defining Roles
roles:
files: 'roles.yaml'
Specify files to serve statically from the Harper HTTP endpoint.
Use the Resource Extension configuration options files
and urlPath
to specify the files to be served.
As specified by Harper's Resource Extension docs, the files
option can be any glob pattern or a glob options object. This extension will serve all files matching the pattern, so make sure to be specific.
To serve the entire web
directory, specify files: 'web/**'
.
To serve only the html files within web
, specify files: 'web/*.html'
or files: 'web/**/*.html'
.
The urlPath
option is the base URL path entries will be resolved to. For example, a urlPath: 'static'
will serve all files resolved from files
to the URL path localhost/static/
.
Given the config.yaml
:
static:
files: 'web/*.html'
urlPath: 'static'
And the file directory structure:
component/
├─ web/
│ ├─ index.html
│ ├─ blog.html
├─ config.yaml
The HTML files will be available at localhost/static/index.html
and localhost/static/blog.html
respectively.