20190917_jeffrey - silenceuncrio/diary GitHub Wiki

0855

繼續 M330 - GPS Track Server 端的佈建

目前花時間熟悉 Express

  • Fast, unopinionated, minimalist web framework for Node.js

有了 express 之後再來跟 Docker 結合一下

注意到該文章如果要配合 Express 裡的範例

Docker file 要修改如下

FROM node:10

# Create app directory
WORKDIR	/usr/scr/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Build app source
COPY . .

EXPOSE 3000
CMD ["npm", "start"]

1040

找一下 express 跟 mongoose 怎麼互動

科普一下

  • MongoDB
    • The database for modern applications
  • mongoose
    • elegant mongodb object modeling for node.js

先單純的從 mongoDB 出發

參考 Getting Started With MongoDB As A Docker Container Deployment

  • In this tutorial we’re going to focus on using Docker to deploy MongoDB as a container and interact with it with the shell client.

1100

M360[release/v1.04] - at 'Firewall > Basic Rule', display the error message while apply fail

commit c9ffe9f51359838c5ae574d80fcdd69509cb0b57
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date:   Tue Sep 17 10:57:53 2019 +0800

    at 'Firewall > Basic Rule', display the error message while apply fail

 proscend/prosrc/www/app/feature/basicRules.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

1315

Getting Started With MongoDB As A Docker Container Deployment

這一篇單純的讓我可以專心在 mongoDB 上面

再來應該要把 express 和 mongoDB 串起來了


Getting Started With MongoDB As A Docker Container Deployment 相同的作者

Building A REST API With MongoDB, Mongoose, And Node.js

繼續看該作者的文章

1405

M360P[release/v1.04] - change wording 'Ping' to 'ICMP' at 'Firewall > Basic Rules' page

commit b3ab51574b4af57d83b294bce5aeda5814d605d8
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date:   Tue Sep 17 14:02:12 2019 +0800

    change wording 'Ping' to 'ICMP' at 'Firewall > Basic Rules' page

 proscend/prosrc/www/app/feature/basicRules.html | 2 +-
 proscend/prosrc/www/app/locale-en.json          | 1 +
 proscend/prosrc/www/app/locale-fr.json          | 1 +
 proscend/prosrc/www/app/locale-zh-tw.json       | 1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

1545

Building A REST API With MongoDB, Mongoose, And Node.js

照著操作

利用 node app.js 執行

➜ express_mongo node app.js
(node:77136) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:77136) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Listening at :3000...

window 端透過 Postman 可以跟我們剛剛的 application 互動

image

到這一步表示 mongoDB 運作正常

我們可以透過 Node.js 跟 mongoDB 互動