Skip to content

Commit

Permalink
Merge pull request #31 from H4ad/feature/azure
Browse files Browse the repository at this point in the history
feat(azure): added support to azure functions http trigger
  • Loading branch information
H4ad authored Jul 16, 2022
2 parents 43e2f20 + 682b406 commit 2efd585
Show file tree
Hide file tree
Showing 26 changed files with 1,441 additions and 95 deletions.
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
[![Commitizen Friendly][commitizen-img]][commitizen-url]
[![Semantic Release][semantic-release-img]][semantic-release-url]

Run REST APIs and other web applications using your existing Node.js application framework (Express, Koa, Hapi and
Fastify), on top of AWS Lambda, Huawei and many other clouds.
Run REST APIs and other web applications using your existing Node.js application framework (Express, Koa, Hapi,
Fastify and tRPC), on top of AWS Lambda, Azure, Huawei and many other clouds.

This library was a refactored version of [@vendia/serverless-express](https://github.com/vendia/serverless-express), I
create a new way to interact and extend event sources by creating contracts to abstract the integrations between each
Expand All @@ -38,6 +38,41 @@ Why you would use this libray instead of [@vendia/serverless-express](https://gi
- Well documented, any method, class, or interface has comments to explain the behavior.
- We have >99% coverage.

# Usage

To start to use, first you need to know what you need to import, let's start showing the [ServerlessAdapter](/docs/api/ServerlessAdapter).

```tsx
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
```

We need to pass to [Serverless Adapter](/docs/api/ServerlessAdapter) the instance of your api, let's look an example with:

- Framework: [Express](../frameworks/express).
- Adapters: [AWS Api Gateway V2 Adapter](../adapters/aws/api-gateway-v2).
- Handler: [Default Handler](../handlers/default).
- Resolver: [Promise Resolver](../resolvers/promise).

```ts
import { ServerlessAdapter } from '@h4ad/serverless-adapter';
import { ExpressFramework } from '@h4ad/serverless-adapter/lib/frameworks/express';
import { DefaultHandler } from '@h4ad/serverless-adapter/lib/handlers/default';
import { PromiseResolver } from '@h4ad/serverless-adapter/lib/resolvers/promise';
import { ApiGatewayV2Adapter } from '@h4ad/serverless-adapter/lib/adapters/aws';

const express = require('express');

const app = express();
export const handler = ServerlessAdapter.new(app)
.setFramework(new ExpressFramework())
.setHandler(new DefaultHandler())
.setResolver(new PromiseResolver())
.addAdapter(new ApiGatewayV2Adapter())
// if you need more adapters
// just append more `addAdapter` calls
.build();
```

# Documentation

See how to use this library [here](https://viniciusl.com.br/serverless-adapter/docs/category/getting-started).
Expand Down
25 changes: 24 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@h4ad/serverless-adapter",
"version": "0.0.0-development",
"description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Huawei and many other clouds.",
"description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Huawei and many other clouds.",
"main": "./lib/index.js",
"files": [
"lib/**/*"
Expand Down Expand Up @@ -54,7 +54,10 @@
"http",
"huawei",
"functiongraph",
"trpc"
"trpc",
"azure",
"azure-functions",
"http-trigger-v4"
],
"bugs": {
"url": "https://github.com/H4ad/serverless-adapter/issues"
Expand Down Expand Up @@ -97,6 +100,7 @@
"typescript": "^4.5.5"
},
"peerDependencies": {
"@azure/functions": ">= 2.0.0",
"@hapi/hapi": ">= 20.0.0",
"@trpc/server": ">= 9.0.0",
"@types/aws-lambda": ">= 8.10.92",
Expand All @@ -109,6 +113,9 @@
"koa": ">= 2.5.1"
},
"peerDependenciesMeta": {
"@azure/functions": {
"optional": true
},
"@hapi/hapi": {
"optional": true
},
Expand Down
Loading

0 comments on commit 2efd585

Please sign in to comment.