<commit_before>Meteor.publish("post_list", function(page_num){
  const posts_per_page = 10;

  //validating the page number
  var page_number = page_num;
  if(!/^[0-9]+$/gi.test(page_num)){
    return [];
  } else if(page_num <= 0) {
    return [];
  }

  return Posts.find({}, {
    limit: posts_per_page,
    skip: (parseInt(page_number) - 1) * posts_per_page
  })
})

Meteor.publish("get_post", function(post_id){
  //validating the id
  if(!post_id.match(/^[0-9A-Za-z]{17}(?=(#[0-9a-zA-Z_-]+)?$)/gi)){
    return [];
  }

  return Posts.find(post_id, {
    limit: 1,
  })
})

Meteor.publish("metadata", function(type){
  if(type === "posts" || type === "works"){
    return MetaData.find({
      type: type
    });
  } else {
    return [];
  }
})
<commit_msg>Fixed post sorting at server side<commit_after>Meteor.publish("post_list", function(page_num){
  const posts_per_page = 10;

  //validating the page number
  var page_number = page_num;
  if(!/^[0-9]+$/gi.test(page_num)){
    return [];
  } else if(page_num <= 0) {
    return [];
  }

  return Posts.find({},{
    limit: posts_per_page,
    skip: (parseInt(page_number) - 1) * posts_per_page,
    sort: {
      createdAt: -1
    }
  })
})

Meteor.publish("get_post", function(post_id){
  //validating the id
  if(!post_id.match(/^[0-9A-Za-z]{17}(?=(#[0-9a-zA-Z_-]+)?$)/gi)){
    return [];
  }

  return Posts.find(post_id, {
    limit: 1,
  })
})

Meteor.publish("metadata", function(type){
  if(type === "posts" || type === "works"){
    return MetaData.find({
      type: type
    });
  } else {
    return [];
  }
})

{'fraction_non_alphanumeric': 0.2042875157629256, 'fraction_numerical': 0.017023959646910468, 'mean_word_length': 3.122077922077922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3063050', 'n_tokens_mistral': 648, 'n_tokens_neox': 610, 'n_words': 106}