Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit bca0a58

Browse files
committed
lots of new features
* Added pagination * Added Search using Typesense * Added Search by IMDB * Added Filtering by category when searching * Added a caching layer on all routes * other QoL improvements
1 parent 93ad899 commit bca0a58

16 files changed

+675
-568
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ dist
128128
.yarn/build-state.yml
129129
.yarn/install-state.gz
130130
.pnp.*
131+
/api/scripts

api/ecosystem.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module.exports = {
22
apps: [{
33
name: 'nq-rarbg',
4-
script: 'src/index.js',
4+
script: 'src/server.js',
55

6-
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
7-
instances: 'max',
86
autorestart: true,
97
watch: false,
108
max_memory_restart: '1G',
119
exec_mode: 'cluster',
1210
env: {
13-
NODE_ENV: 'development'
11+
NODE_ENV: 'development',
12+
instances: '1'
1413
},
1514
env_production: {
16-
NODE_ENV: 'production'
15+
NODE_ENV: 'production',
16+
instances: 'max'
1717
}
1818
}]
1919
}

api/models/Item.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const mongoose = require('mongoose')
2+
const MongoPaging = require('mongo-cursor-pagination')
3+
4+
const ItemSchema = new mongoose.Schema({
5+
hash: {
6+
type: String,
7+
required: true,
8+
unique: true
9+
},
10+
title: {
11+
type: String,
12+
required: true
13+
},
14+
dt: {
15+
type: String,
16+
required: true
17+
},
18+
cat: {
19+
type: String,
20+
required: true
21+
},
22+
size: {
23+
type: Number,
24+
required: true
25+
},
26+
uploader: {
27+
type: String,
28+
required: true
29+
},
30+
imdb: {
31+
type: String,
32+
required: false
33+
}
34+
})
35+
36+
// Required for pagination
37+
ItemSchema.plugin(MongoPaging.mongoosePlugin)
38+
39+
// Index for listing all torrents
40+
ItemSchema.index({ dt: 1, _id: 1 })
41+
42+
// Index for full-text search (required for search to work)
43+
ItemSchema.index({ title: 'text', _id: 1 })
44+
45+
// Index for listing all categories
46+
ItemSchema.index({ cat: 1, _id: 1 })
47+
48+
// Index for getting torrents from specific categories
49+
ItemSchema.index({ cat: 1, dt: 1, _id: 1 })
50+
51+
module.exports = mongoose.model('Item', ItemSchema)

0 commit comments

Comments
 (0)