npm init -y
npm install --save express
npm install --save-dev @babel/core @babel/node @babel/preset-env
Create .babelrc file in main backend directory with the following,
{
"presets": ["@babel/preset-env"]
}
this gives us modern ES6 syntax using server.js
npx babel-node src/server.js
npm install --save body-parser
npm install --save-dev nodemon
for hot-encoding/refreshing
npx nodemon --exec npx babel-node src/server.js
mkdir -p /data/db
mongod
npm install --save mongodb
-
Create EC2 Instance
-
Create Key Pair
-
SSH in
ssh -i .\aquinas-app-key.pem ec2-user@
- Install git
sudo yum install git
- Install NPM (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 12.18.4
npm install -g npm@latest
- Install MongoDB (https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/)
sudo nano /etc/yum.repos.d/mongodb-org-4.4.repo
Paste the below into the file
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
sudo yum install -y mongodb-org
sudo service mongod start
mongo
use aquinas-db;
- Clone git code
git clone https://github.com/conradbm/aquinas-app
cd aquinas-app/aquinas-backend
npm install
- Run the server
npm install -g forever
forever start -c "npm start" .
forever list
- Map port 8000 to port 80 on AWS
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000
- Go manually to security groups for this EC2 instance and change port 80 to ANYWHERE.
> var file = cat('.aquinas_new.json');
> use aquinas-db
> var o = JSON.parse(file);
> db.articles.insert(o);
> var file = cat('.aquinas_similarity.json');
> use aquinas-db
> var o = JSON.parse(file);
> db.articles.insert(o);
> db.articles.createIndex({"questionTitle":"text", "articleTitle":"text", "articleObjections":"text", "articleBody":"text", "articleReplyToObjections":"text"});
>db.articles.findOne( { $text: { $search: "Plato" } } );
use aquinas-db;
db.createCollection("history");
https://aws.amazon.com/getting-started/hands-on/get-a-domain/