NTERAC

About

Nterac is a minimal HTTP API server using Deno.

Usage

Start the server

Init a server in a main.ts:

import { Server } from "https://deno.land/x/nterac/mod.ts";

// use it only in local developement to generate the exportmap.ts file
Deno.env.set('NTERAC_DEVMODE', 'on');

const server = await new Server().init();
server.serve();

After that the serve function will use the files in the api folder.

Run deno run --allow-all main.ts.

To activate dev mode, which will generate the exportmap.ts file, set an environment variable NTERAC_DEVMODE to on;

The api folder

The api folder should contain the routes. Routes are simple TypeScript files. An example would be the file api/hello.ts:

export default function (_req: Request) {
  return new Response('Hello World!');
}

Root files are files in the root of a directory. These are named index.ts. Hidden files are files hidden from the route detection. These start with a _. For example: _this_is_hidden.ts. Folders also work like this.

Keep in mind

There's a difference between /hello/ and /hello. See root files. If the file is named something like api/users.ts, then it is on the /users route, else if it is like api/human/index.ts then on the /human/ route. This is a hobby project, but planned to maintain and update. This project is in it's early stages, so it might be unstable, and things might change with later updates.

To try it out, clone the repo, start the main.ts file using deno run --allow-all main.ts.