The Eggjs+MongoDB+GraphQL based web server implementation for children myopia control community application.
related projects - WeChat Mini Program | CMS
‼️ This project is better to be used as sample code for learning purpose, instead of an application in production.
Myopia (or nearsightedness) is very common. One out of two people (50%) have it. With myopia, the eye is longer than normal from front to back, or the cornea (the clear window at the front of the eye) is too steeply curved. This makes things that are far away from you look blurry. Myopia is corrected with glasses, contact lenses or surgery in some cases. Having myopia can increase your chances of having some eye problems later, like cataract, glaucoma and retinal detachment.
Studies show myopia is becoming more common among children. While there is no proven direct link, research suggests that children who spend more time indoors doing near-focused activities (such as computer work, video games, and reading) have higher rates of myopia than those who spend more time outdoors.
Doctors are looking at ways to slow the progression of myopia in children. While myopia cannot be reversed, the goal of treatment is to keep it from getting worse. This can protect a child’s eye health in the future, despite still needing to wear glasses or contact lenses.[1]
[1]. Myopia Control in Children. (2020). Retrieved 28 May 2021, from https://www.aao.org/eye-health/treatments/myopia-control-in-children
Please refer to this for more information.
- install redis
- start redis -
sudo systemctl start redis
- start redis -
- install elasticsearch RPM
- start elasticsearch -
sudo systemctl start elasticsearch.service
- open
http://localhost:9200/articles/_mapping?pretty=true
- start elasticsearch -
- install mongodb
makir /data && mkdir /data/mongodb
- start mongodb deamon -
mongod --auth --fork --dbpath /data/mongodb --logpath /var/log/mongodb/mongod.log
- install node
- install nginx(not necessary for local development)
- config nginx
- start nginx -
nginx
export JWT_SECRET_KEY='YOUR_JWT_SECRET_KEY' &&
export WECHAT_MINI_APP_ID='YOUR_WECHAT_NIMI_APP_ID' &&
export WECHAT_MINI_APP_SECRET='YOUR_WECHAT_MINI_APP_SECRET' &&
export MONGODB_URL='YOUR_MOGONDB_URL' &&
export ALIYUN_USER_BUCKET='YOUR_ALIYUN_USER_BUCKET' &&
export ALIYUN_BUCKET='YOUR_ALIYUN_BUCKET' &&
export ALIYUN_ACCESS_KEY_SECRET='YOUR_ALIYUN_ACCESS_KEY_SECRET' &&
export ALIYUN_ACCESS_KEY_ID='YOUR_ALIYUN_ACCESS_KEY_ID' &&
export ALIYUN_REGION='YOUR_ALIYUN_REGION'
Please get the permission to access the remote host first.
# Connect to the host by using SSH Tunnel to bridge the database port to your local.
ssh -L27018:localhost:27017 root@x.x.x.x
# Start the local server.
npm install
npm run dev
open http://localhost:7001/graphql
npm run stop-gamma
npm install
npm run start-gamma
open http://localhost:7001/graphql
npm run stop
npm install
npm run start
open http://localhost:7777/graphql
1. how to use elasticvue to configure the elasticsearch?
Please add below configurations to the /etc/elasticsearch/elasticsearch.yml
# allow CORS requests from https://app.elasticvue.com
http.cors.enabled: true
http.cors.allow-origin: "https://app.elasticvue.com"
You could use mongoexport or any other GUI tools if you know.
export MONGODB_URL="MONGODB_URL"
mongoexport --uri=MONGODB_URL --collection=articles --out=articles.json
Or you could consider mongodump.
mongodump --uri=MONGODB_URL -o=gugudump
https://pranavprakash.net/2017/02/04/automate-mongodb-backups-using-cron-and-shell-script/
Please refer to the script in script/mongodb_dump.sh
.
# use SSH Tunnel to bridge the port to your local.
ssh -L9201:localhost:9200 root@x.x.x.x`
Visit https://app.elasticvue.com/
and connect to localhost with port as 9201。
- enable auth and create admin user
mongo
use admin
db.createUser({ user: "opsAdmin", pwd: passwordPrompt(), roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]})
- create the new database
- create the admin roles for the new database
server {
listen 443;
server_name YOUR_DOMAIN; # your domain
# ssl config
ssl on;
ssl_certificate YOUR_CERTIFICATE_CERT; # your certificate's crt file name
ssl_certificate_key YOUR_CERTIFICATE_KEY; # your certificate's key file name
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:7001;
}
}
This repo is created from egg-graphql-boilerplate.
Please open an issue for any questions,and I will respond as soon as possible。
This project is MIT licensed.