本 Project 主要是以 Node.js + MongoDB with APi design 的部分。
開啟您指定的路徑下終端機,在終端機內輸入
(以下全部步驟皆在 終端機 內部執行)
git clone https://github.com/maxyihsunchou/bananapi-training-node.js-database.git
cd bananapi-training-node.js-database
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install -y mongodb
sudo vim /lib/systemd/system/mongod.service
在此檔案內貼上以下文字
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
按ESC 之後以 :wq
儲存變更
在目錄裡下輸入
sudo service mongod start
開啟 MongoDB 的服務
與 伺服器
npm start
在 Google Chrome 的網址列中輸入
http://localhost:3000/
如果看到 Welcome to Express 就是成功了。
localhost:3000/control/article/add/
localhost:3000/api/article/
localhost:3000/api/article/<your_id_here>