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_HOSTDB_USERDB_PASSWORDDB_NAMEUse 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 devThis command uses the Serverless Offline plugin to emulate AWS Lambda and API Gateway on your local machine.
To run tests:
yarn testThis will run all tests located in the test folder.
Method: POSTEndpoint: /registerAuthorization: NoneRequest Body:
{
"username": "exampleUser",
"password": "examplePassword"
}
Method: POSTEndpoint: /loginAuthorization: NoneRequest Body:
{
"username": "exampleUser",
"password": "examplePassword"
}
Method: POSTEndpoint: /logoutAuthorization: Bearer token requiredRequest Body:None
Method: POSTEndpoint: /productsAuthorization: Bearer token requiredRequest Body:
{
"name": "productName",
"description": "productDescription",
"quantity": 10,
"price": 99.99,
"categoryId": "categoryId"
}
Method: GETEndpoint: /productsAuthorization: Bearer token requiredRequest Body:None
Method: DELETEEndpoint: /productsAuthorization: Bearer token requiredRequest Body:
{
"productId": "productId"
}
Method: DELETEEndpoint: /productsAuthorization: Bearer token requiredRequest Body:
{
"productId": "productId",
"name": "updatedName",
"description": "updatedDescription",
"quantity": 5,
"price": 79.99,
"categoryId": "newCategoryId"
}
Method: POSTEndpoint: /categoriesAuthorization: Bearer token requiredRequest Body:
{
"name": "categoryName"
}
Method: GETEndpoint: /categoriesAuthorization: Bearer token requiredRequest Body:None
Runs the application locally.
yarn devDeploys the application to AWS.
yarn pushRuns the test suite.
yarn test