This is a template for creating a serverless microservice using Serverless Framework, Nest.js on AWS Lambda.
Before getting started, make sure you have the following installed:
- Node.js (v14 or higher)
- Serverless Framework (global installation)
Follow these steps to set up and deploy the microservice:
- Clone this repository:
$ git clone https://github.com/ekrenz-developer/serverless-nest-microservice-template.git
- Navigate to the repository directory:
$ cd serverless-nest-microservice-template
- Install the dependencies:
$ npm install
- Configure your AWS credentials:
- Create a
credentials
file in the~/.aws/
directory (if it doesn't exist) and add your AWS credentials:
- Create a
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
region = YOUR_REGION
- Deploy the microservice to AWS Lambda:
$ sls deploy
# watch mode
$ npm run start:dev
The project follows the standard structure of a Nest.js application. Here's a description of key directories:
src
: Contains the source code of the application.src/{module}/handlers
: Defines the server's endpoint handlers.src/{module}/services
: Defines the handlers' services.src/common
: Contains common files and utilities.serverless.yml
: Serverless Framework deployment configuration file.
If you'd like to contribute to this project, follow these steps:
- Create a fork of the repository.
- Create a branch for your feature:
git checkout -b your-feature-branch
. - Make the changes and commit:
git commit -m 'Description of the changes'
. - Push the changes to your forked repository:
git push origin your-feature-branch
. - Open a pull request in the original repository.
This project is licensed under the MIT License. See the LICENSE file for more details.