This assignment is for creating rest end point for checking health end point for get end point, user endpoints for put, post and get methods.
- Any IDE/ text editor of choice.
- Postman
- Pgadmin 4
- The project resides on the repo webapp in Anutej-Northeastern organization.
- To make changes to the repo code, fork the repo and clone it locally by running the below command:
git clone <link to forked repo>
- After cloning the repo locally run the below command after opening the project in IDE of choice:
npm i
- Open Pgadmin to create a table that follows the below sql schema of the table
CREATE TABLE users ( id integer, account_created timestamp without time zone, account_updated timestamp without time zone, username text, password text, first_name text, last_name text );
- Once the project is open you can run the below command to run tests that are pre written in the codebase :
npm test
- To test the API end points manually, move to the root folder of the project and run
node server.js
- Once you get a prompt that "server is listening on port 3300" open postman or any rest client.
- The end points and the expected results are mentioned in swaggerLink
- Once the changes are made in the feature branch locally, add the changed files to the branch using the below command:
git add <file names>
- Once this is done, commit the changes and push them to the feature branch.
- Now create a Pull request to merge the changes to the organization repo after the github action runs successfully.
Node.js -19.x
Below are the dependencies used for building the project:
"bcrypt": "^5.1.0",
"cors": "^2.8.5",
"debug": "^4.3.4",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"pg": "^8.9.0",
"supertest": "^6.3.3",
"bcrypt": "^5.1.0",
"cors": "^2.8.5",
"debug": "^4.3.4",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"pg": "^8.9.0",
"supertest": "^6.3.3",
"jest": "^29.4.1",
"sequelize": "^6.28.0",
"sequelize-cli": "^6.6.0"
- Install sequelize, sequelize-cli, pg package by navigating to the root folder.
- Create a new folder to hold all the sequelize files by executing the below command
mkdir sequelize
- Change to the directory by executing this command:
cd sequelize
- now run npx sequelize-cli init to create necessary files and folders
- To create user and product models run below commands:
npx sequelize-cli model:generate --name User --attributes id:number,first_name:string,last_name:string,password:string,username:string
npx sequelize-cli model:generate --name Product --attributes id:number,name:string,description:string,sku:string,manufacturer:string,quantity:number
- Running the above commands creates the migration files that are needed.
We follow following steps while creating ami image for packer
- cd to packer folder or to the folder that has the packer file
- packer init . - packer initialize all the packer files
- packer fmt . - packer format all the packer files
- packer validate . - packer validate all the packer files
- packer build . - packer build the ami image from the validated packer file
- sudo systemctl status webapp.service -to restart webapp service on ec2
- cat ~/.bash_history - to print history without line numbers
- packer build -var-file="variables.pkrvars.hcl" . -gives values from this file to build