RESTful APIs for V2EX. This is the back-end of bv2ex web application.
Notice: Recently automatic update function was added. If you checked out the latest code, it is enabled by default. To disable this feature you need to set autoUpdate
to false
in config.js
.
To update, see Update
section below.
bv2ex is a redesigned V2EX web application. Its goal is to provide a better user experience and more useful features with new web technologies.
Node.js >= 10.15.3
git clone https://github.com/7nights/get-v2ex.git --depth 1
npm install
npm run init
(This step is optional.) You can enable FCM to notifiy users when they get new notifications. This need you to configure both the server side and client side. Follow the instruction below to configure your server.
Go to Firebase console to add a project.
- In the Firebase console, open Settings > Server Accounts.
- Click Generate New Private Key, then confirm by clicking Generate Key.
- Securely store the JSON file containing the key on your server.
- Fill in
serverKeyPath
with the absolute path of the key file. - Fill in
databaseURL
. You can find it in theAdmin SDK configuration snippet
at step 2.
Before you configure Nginx, you need to install bv2ex first.
You may use get-v2ex to serve both the RESTFul APIs and static resources of the web application.
To achieve this, we need to add 2 rules to tell Nginx how it should rewrite requests. For example, if we configure clientAddress
as https://example_domain
in get-v2ex/public/config.js
, we'll need to rewrite all the client resource requests to add '/static'
as a prefix. (This is because bv2ex resources are served under the /static
scope by default.)
So eventually you may add something like the following to server
section:
index static/index.html;
# configure serverAddress in your config.js as 'https://[your_domain.com]/api'
location ~ ^/api/(.*) {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://127.0.0.1:3001;
}
# treat other requests as static resources
location ~ ^/(.*) {
rewrite ^/(.*) /static/$1 break;
proxy_pass http://127.0.0.1:3001;
}
You can use some tools to manage your bv2ex server process such as pm2 or forever.
npm i -g forever
forever start index.js
git pull
npm i
forever restart index.js