Environment Configuration
MacOS + NodeJS + MongoDB + Redis
Node is already installed by default.
1. Install MongoDB:#
Download the MacOS version of MongoDB from What Is MongoDB?www.mongodb.com/what-is-mongodb and extract it.
Add the bin directory to the environment variable. Create a log directory and a data/db directory in the MongoDB directory. Create a mongo.conf file and write the following configuration:
dbpath=/mongodb/data/db
logpath=/mongodb/log/mongo.log
logappend=true
journal=true
quiet=true
port=27017
fork=true
Start MongoDB based on the configuration file:
mongod -f ./mongo.conf
Connect to MongoDB using the following command:
mongo
Create the easymock database:
use easymock
Use the following command to view the databases:
show dbs
If the easymock database is not displayed, insert a data entry to make it appear:
db.easymock.insert({"name": "test"})
Run the following command again:
show dbs
The easymock database should now be displayed.
2. Install Redis:#
Download Redis from https://redis.io/, extract it, and add redis/src/ to the environment variable. Start Redis by executing redis-server redis.conf.
Install easy mock
easy mock source code address:
easy-mock/easy-mockgithub.com/easy-mock/easy-mock.git
Execute the following commands:
git clone https://github.com/easy-mock/easy-mock.git
yarn
In the config/default.json file:
{
"port": 7300,
"host": "localhost",
"pageSize": 30,
"proxy": false,
"db": "mongodb://localhost:27017/easymock",
"unsplashClientId": "",
"redis": {
"keyPrefix": "[Easy Mock]",
"port": 6379,
"host": "localhost",
"password": "12345678",
"db": 0
},
"blackList": {
"projects": [],
"ips": []
},
"rateLimit": {
"max": 1000,
"duration": 1000
},
"jwt": {
"expire": "14 days",
"secret": "shared-secret"
},
"upload": {
"types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
"size": 5242880,
"dir": "../public/upload",
"expire": {
"types": [".json", ".yml", ".yaml"],
"day": -1
}
},
"ldap": {
"server": "",
"bindDN": "",
"password": "",
"filter": {
"base": "",
"attributeName": ""
}
},
"fe": {
"copyright": "",
"storageNamespace": "easy-mock_",
"timeout": 25000,
"publicPath": "/dist/"
}
}
Modify the configurations for MongoDB and Redis.
Execute the following command:
yarn dev
Test if the installation is successful by accessing http://localhost:7300. If the page appears as shown in the image, the configuration is successful.
Start easy mock using pm2
Package the static resources:
yarn build
Install pm2 globally:
yarn global add pm2
Start easy mock:
NODE_ENV=production pm2 start app.js
After starting, you can access easy mock.
This article is synchronized and updated to xLog by Mix Space.
The original link is https://liu-wb.com/posts/default/2