Giter VIP home page Giter VIP logo

social-king's Introduction

Tribe Social

Admin App Homepage:

Table of Contents for this Repo:


About

We empower shopify store owners to promote whatever products they like alongside user-generated content.

But, what if a store owner is too lazy to go through every single piece of new shopper content and set the right products to promote alongside it? After all, this app could help you generate thousands of new pages on your site.

No time? No problem. Let our AI-powered Recommendation Algorithm help you show the right products to the right shoppers.

Admin App Blog Update Page:

Proxy App NewsFeed:

Technologies

  Admin Frontend: NextJS 
  Proxy: NodeJS (Routes, Controllers)
  Admin Backend: NodeJS (Routes, Controllers)

Getting Started

The easiest way to get started is to clone the repository:

# Get the latest snapshot
git clone https://github.com/ElishaKay/social-king

# Running the Admin Backend
cd Admin-Backend
npm install
npm start

# Running the Admin Frontend
cd Admin-Frontend
npm install
npm run dev

# Running the Proxy Server
cd Proxy
npm install
npm start

Proxy App Structure

Proxy Views

Proxy Routes and Controllers


Proxy API Routes are defined here.

The Proxy API Controller Functions are defined here.

Importing Controller Functions into Route Files

Controller functions are imported and injected into the routes files like so (Example from Proxy/routes/proxy-routes/blog.js: ):

const {
    create,
    list,
    listForSitemap,
    listAllBlogsCategoriesTags,
    read,
    remove,
    listByUser
} = require('../proxy-controllers/blog');

When an HTTP Request Hits The Server

Here's another exampe from that same route file mentioned above, Proxy/routes/proxy-routes/blog.js:

router.post('/user/blog', requireSignin, authMiddleware, create);

That means, when a Post request is made to '/proxy/blog', the Req, Res, and Next objects are passed to the requireSignin, adminMiddleware, and create in sequential order.

The Req, Res, and Next() Conveyor belt

The Req object contains all the functionality required for handling a request. The Res object contains all the functionality required for sending back a response. The Next function contains all the functionality required for sending Req & Res into the next function in the Conveyor Belt.

The easiest way to think of these 3 objects is as if they are going through a Manufacturing Conveyor Belt. Each function (also called: 'middleware') has the ability to tack new fields unto these objects.

For example, in the authMiddleware function, we grab the email from the POST query string, search the database for that user, and then tack the user object unto the Req object, like so:

exports.authMiddleware = (req, res, next) => {
    // grab the email from the POST query string
    let email = req.query.email.toLowerCase();
    ... 
    // search the database for the user with the given email
    User.findOne({ email: email }).exec((err, user) => {
    ...
    //tack the user object unto the Req object so that the user object can be accessed by the next middleware functions down the chain 
    req.user = user;
    ...
    // Pass the req, res, and next() objects into the next function in the chain
    next();

The benefit of this is that when we get to the next function in the chain, the blogCreate function, we can use the user object we got the previous middleware function, like so:

blog.postedBy = req.user._id;

social-king's People

Contributors

elishakay avatar iyerushalmi 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.