Giter VIP home page Giter VIP logo

get-v2ex's Introduction

get-v2ex

RESTful APIs for V2EX. This is the back-end of bv2ex web application.

Changelog

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

bv2ex-1

bv2ex-2

bv2ex-dark

bv2ex is a redesigned V2EX web application. Its goal is to provide a better user experience and more useful features with new web technologies.

Requirements

Node.js >= 10.15.3

Installation

git clone https://github.com/7nights/get-v2ex.git --depth 1
npm install
npm run init

Configure FCM

(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.

Step 1. Add a project

Go to Firebase console to add a project.

Step 2. Create a server account

  1. In the Firebase console, open Settings > Server Accounts.
  2. Click Generate New Private Key, then confirm by clicking Generate Key.
  3. Securely store the JSON file containing the key on your server.

Step 3. Edit config.js

  1. Fill in serverKeyPath with the absolute path of the key file.
  2. Fill in databaseURL. You can find it in the Admin SDK configuration snippet at step 2.

Configure Nginx

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;
}

Start your server

You can use some tools to manage your bv2ex server process such as pm2 or forever.

npm i -g forever
forever start index.js

Update

git pull
npm i
forever restart index.js

get-v2ex's People

Contributors

7nights avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.