Skip to content

The hyper Config File โ€‹

The Config file is the core manifest for hyper, it pulls all of the adapters into the fold, configures, and applies them to hyper Core.

The Config file is where you choose the App and set of Adapters you would like hyper Core to use.

A Config file will look like this:

// hyper App
import express from "";

// hyper Adapters
import mongodb from "";
import redis from "";

// hyper Middleware
import { auth } from "./auth.ts";

export default {
  app: express,
  adapters: [
    { port: "data", plugins: [mongodb({ url: Deno.env.get("MONGO_URL") })] },
    { port: "cache", plugins: [redis({ url: Deno.env.get("REDIS_URL") })] },
    // ... any other adapters
  middleware: [auth],
import { jwt, type express } from "./deps.ts";

 * Given a sub and secret, return a hyper Custom Middleware that will
 * check that all incoming requests have a properly signed jwt token
 * in the Authorization header as a bearer token
export const auth =
  ({ sub, secret }: { sub: string; secret: string }) =>
  (app: express.Express) => {
     * Extract the bearer token from the header, and verify it's
     * signature and sub matches expected
    const verify = async (header: string) => {
      const payload = await jwt
        .verify(header.split(" ").pop() as string, secret, "HS256")
        .catch(() => {
          throw { name: "UnauthorizedError" };
       * Confirm sub matches
      if (payload.sub !== sub) throw { name: "UnauthorizedError" };

    app.use(async (req, _res, next) => {
      await verify(req.get("authorization") || "Bearer notoken")
        .then(() => next())
        // pass error to next, triggering the next error middleware to take over

        err: unknown,
        _req: express.Request,
        res: express.Response,
        next: express.NextFunction
      ): unknown => {
        if (err && === "UnauthorizedError") {
          return res.status(401).send({ ok: false, msg: "not authorized" });
        // Trigger the next error handler

    return app;

You can then invoke hyper Core in the same directory using Deno:

deno run -A

This will download hyper Core, load your configuration file, and start up a hyper Server using the App, Middleware and Adapters you've specified in the config.

Start hyper Programmatically โ€‹

You can also start hyper by importing it using Deno

// hyper Core
import hyper from "";

  // your hyper config here