Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:59:04+00:00 2026-06-14T21:59:04+00:00

given a RESTful web service that allows different users to post different articles For

  • 0

given a RESTful web service that allows different users to post different articles

For defining the GET function on the server-sidem
i suppose there should be async functions like list, getTopViewed, getTopFavorite etc functions on the server-side

is the following correct then?

exports.get = function(req, res) {

    db.articles.list(function etc)
    db.articles.getTopViewed(function etc)
    db.articles.getTopFavorite(function etc)
}

NOTE: where list, getTopViewed and getTopFavorite are defined in another JavaScript file

In another JS file:

exports.list = function(callback){
  // acts as async callback 
  var result = ArticleModel.find({}, function(err, articles){
    callback(null, articles)                                                    
  });
  return result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:59:05+00:00Added an answer on June 14, 2026 at 9:59 pm

    I recommend using something like Connect or Express. It has a router that makes this a bit easier. Setup and usage look something like this:

    var express = require("express"),
        db = require('./yourdb.js');
    
    var app = express.createServer();
    
    app.configure(function(){
        app.use(app.router);
    });
    
    app.get("/articles/", function(req, res){
        db.list(function(err, articles){
           res.writeHead(200);
           // you probably want to do something more complex here
           res.end(JSON.stringify(articles));
        });
    });
    
    app.get("/articles/top", function(req, res){
        // res.end(<top articles go here>);
    });
    

    Here’s a link to the docs for Express’ router: Application Routing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a webservice that allows users to post files and then retrieve
I wanted to ask again my Question. I'm developing a restful web service that
I am building a RESTful web service in PHP that accepts JSON as its
Given that RESTful web services are all based around the sacred idea that everything
I'm curious about using Lisp to underpin a modern RESTful web service, but given
I am implementing jersey restful web service to get JSON Object directly. For it
I've been given a Flex application which made use of a RESTFUL service. I've
Given that the web application doesn't have su privileges, I'd like to execute a
i have this restful web service where i actually return a list<> in c#.
I have a RESTful Web Service hosted in IIS 6.0, I am able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.