0.0.2 • Published 10 months ago

@ape-framework/server v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Ape Framework

Node.js API framework.

NPM packages:

GitHub repository: ApeCommerce/ape-framework

Starter project

Use @ape-framework/starter to quickly create a Node.js application using Ape Framework.

Installation

Server side:

npm install @ape-framework/server

Client side or within a shared library:

npm install @ape-framework/common

The common package contains useful interfaces for a client application to interact with the server. It is a subset of the server package and has no dependency.

Hello Ape!

Let's create an API serving a /hello endpoint.

// boot.ts
import { Boot } from '@ape-framework/server/boot';
import { Bundle } from '@ape-framework/server/boot/bundle';
import { send } from '@ape-framework/server/api/handler';

const welcomeBundle: Bundle = {
  bundleId: 'welcome',
  name: 'Welcome',
  routes: [
    {
      endpoint: {
        method: 'GET',
        path: '/hello',
      },
      handler: async (request, reply) => send(reply, 'Hello Ape!'),
    },
  ],
};

const boot: Boot = {
  bundles: async () => [welcomeBundle],
};

export default boot;

Start the API server:

npx ape-cli-ts api start

Request the API:

curl http://localhost:3000/hello