This is a serverless simplified multi-platform retail store application built with AWS Lambda, Node.js, and Typescript. The application uses MySQL for the database and is managed using the Serverless Framework. The package manager used is Yarn.
- Node.js (18.x)
- Yarn (3.6.4)
- Serverless Framework
- AWS CLI
- MySQL
-
Clone the repository
git clone https://github.com/Success0452/RIS-Backend.git cd RIS-Backend
-
Install dependencies
yarn install
-
Setup environment variables Store your environment variables in AWS Systems Manager Parameter Store (SSM). Example variables include:
DB_HOST
DB_USER
DB_PASSWORD
DB_NAME
Use the AWS CLI to set these variables:aws ssm put-parameter --name "/env/DB_HOST" --value "your-db-host" --type "String" aws ssm put-parameter --name "/env/DB_USER" --value "your-db-user" --type "String" aws ssm put-parameter --name "/env/DB_PASSWORD" --value "your-db-password" --type "String" aws ssm put-parameter --name "/env/DB_NAME" --value "your-db-name" --type "String" aws ssm put-parameter --name "/env/JWT_SECRET" --value "your-db-name" --type "String"
To run the application locally:
yarn dev
This command uses the Serverless Offline plugin to emulate AWS Lambda and API Gateway on your local machine.
To run tests:
yarn test
This will run all tests located in the test folder.
Method: POST
Endpoint: /register
Authorization: None
Request Body:
{
"username": "exampleUser",
"password": "examplePassword"
}
Method: POST
Endpoint: /login
Authorization: None
Request Body:
{
"username": "exampleUser",
"password": "examplePassword"
}
Method: POST
Endpoint: /logout
Authorization: Bearer token required
Request Body:None
Method: POST
Endpoint: /products
Authorization: Bearer token required
Request Body:
{
"name": "productName",
"description": "productDescription",
"quantity": 10,
"price": 99.99,
"categoryId": "categoryId"
}
Method: GET
Endpoint: /products
Authorization: Bearer token required
Request Body:None
Method: DELETE
Endpoint: /products
Authorization: Bearer token required
Request Body:
{
"productId": "productId"
}
Method: DELETE
Endpoint: /products
Authorization: Bearer token required
Request Body:
{
"productId": "productId",
"name": "updatedName",
"description": "updatedDescription",
"quantity": 5,
"price": 79.99,
"categoryId": "newCategoryId"
}
Method: POST
Endpoint: /categories
Authorization: Bearer token required
Request Body:
{
"name": "categoryName"
}
Method: GET
Endpoint: /categories
Authorization: Bearer token required
Request Body:None
Runs the application locally.
yarn dev
Deploys the application to AWS.
yarn push
Runs the test suite.
yarn test