Git Product home page Git Product logo

serverless-clean-api-domain-example's Introduction

serverless-simple-api

The purpose of this repository is to develop a basic/clean serverless API using the same concepts as standards frameworks. (.net, laravel, nestJs, etc)

Motivation:point_up:

Web APIs developed using Laravel, .NET, NodeJs, etc use many concepts, including:

  • Dependency Injection (IOC)
  • Domain Layer (Services: Business Roles)
  • Repository Layer - IO/Database operations
  • Declarative Routes (Decorators - ts, attributes - .NET, etc)
  • Cache
  • Middlewares, Interceptors.
  • Request Validations
  • Authentication & Authorization
  • Mappers, DTOs.

Should be easy and simple to develop, test and deploy a serverless API that has all these features and more

Goal ๐Ÿ“‹

Set up a testable serverless web api on AWS Serverless environment that can be deployed easily and have all the basic concepts above available.

Show how serverless environments are flexible and simple to use, test and deploy.

Stack ๐Ÿš€

  • Serverless Framework: Deploy and run the API locally.
  • Docker: Database Local container.
  • Webpack: Generate all bundles for serverless functions.
  • Prisma: SQL Database client
  • Inversify: IOC Container
  • Github Actions: CI/CD

Running/using it: ๐Ÿ”จ

  1. Run yarn to install dependencies
  2. Run docker-compose up -d to create the database container. (Note: The .env file is committed to this repository but in production apps you should not push .env in your github repository. You can use instead CI/CD tools to set your secrets or a service like AWS Secrets Manager.
  3. Run yarn migrate to create your database tables. Note: that is experimental according to Prisma documentation
  4. Run yarn generate to generate prisma client.
  5. Run yarn dev to run it locally.
  6. You can use tools as postman or insomnia to make easier to test the api. If you prefer to use the second option just import the file insomnia.json available on the project root folder.

Folder/structure ๐Ÿ“

  • core/api: All core components for api: container, middlewares, providers.
  • http: All API Resources & Methods.
  • domain: Domain Layer
  • db: DB Service provider

Coming Next ๐Ÿ“

I'll try to add many more features to this sample:

  • Tests and TDD.
  • Deployment, CI/CD on AWS (Github actions, secret manager)
  • Event Driven Architecture (Introduce event bridge)
  • Authentication & Authorization (AWS Cognito)
  • Cache (Redis)
  • Request validations/dto parsing.
  • GraphQL Api using Apollo Server and nexus-prisma.

serverless-clean-api-domain-example's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar lucashfreitas avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.