Skip to main content

Installation

System Requirements:

Automatic Installation

To get started, you can scaffold the project with the mbc-cqrs-serverless CLI. To scaffold the project with the mbc-cqrs-severless CLI, run the following commands. This will create a new project directory, and populate the directory with the initial core mbc-cqrs-severless files and supporting modules, creating a conventional base structure for your project.

npm i -g @mbc-cqrs-severless/cli
mbc new project-name

If you're new to mbc-cqrs-serverless, see the project structure docs for an overview of all the possible files and folders in your application.

Run the Development Server

  1. Run cp .env.local .env to create the environment variables file.
  2. Run npm install to install the required dependencies.
  3. Run npm run build to the build project using development mode.
  4. Open in other terminal session and run npm run offline:docker
  5. Open in other terminal session and run npm run migrate to migrate RDS and dynamoDB table
  6. Finally, run npm run offline:sls to start serverless offline mode.

After the server runs successfully, you can see:

DEBUG[serverless-offline-sns][adapter]: successfully subscribed queue "http://localhost:9324/101010101010/notification-queue" to topic: "arn:aws:sns:ap-northeast-1:101010101010:MySnsTopic"
Offline Lambda Server listening on http://localhost:4000
serverless-offline-aws-eventbridge :: Plugin ready
serverless-offline-aws-eventbridge :: Mock server running at port: 4010
Starting Offline SQS at stage dev (ap-northeast-1)
Starting Offline Dynamodb Streams at stage dev (ap-northeast-1)

Starting Offline at stage dev (ap-northeast-1)

Offline [http for lambda] listening on http://localhost:3002
Function names exposed for local invocation by aws-sdk:
* main: serverless-example-dev-main
Configuring JWT Authorization: ANY /{proxy+}

┌────────────────────────────────────────────────────────────────────────┐
│ │
│ ANY | http://localhost:3000/api/public │
│ POST | http://localhost:3000/2015-03-31/functions/main/invocations │
│ ANY | http://localhost:3000/swagger-ui/{proxy*} │
│ POST | http://localhost:3000/2015-03-31/functions/main/invocations │
│ ANY | http://localhost:3000/{proxy*} │
│ POST | http://localhost:3000/2015-03-31/functions/main/invocations │
│ │
└────────────────────────────────────────────────────────────────────────┘

Server ready: http://localhost:3000 🚀

You can also use several endpoints:

note

In the local environment, if you have trouble with the npm run migrate command or cannot log in with local Cognito, you will need to add more permissions to files and folders using the command below:

sudo chmod -R 777 ./infra-local/cognito-local
sudo chmod -R 777 ./infra-local/cognito-local/db/clients.json
sudo chmod -R 777 ./infra-local
sudo chmod -R 777 ./infra-local/docker-data/
sudo chmod -R 777 ./infra-local/docker-data/dynamodb-local