This repository has been archived by the owner on Mar 19, 2022. It is now read-only.
/
index.js
271 lines (230 loc) · 6.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
const request = require('request');
const https = require("https");
const express = require('express');
const bodyParser = require("body-parser");
const profile = require('./profile');
const mp = require('./mp');
const connect = require('./connect');
const chat = require('./chat');
const search = require('./search');
const fanart = require('./fanart');
const fanfic = require('./fanfic');
const news = require('./news');
const other = require('./other');
const notif = require('./notif');
const chars = require('./chars');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var router = express.Router();
router.route('/')
// GET
.get(function(req,res){
res.send('API AnimationSource.org');
})
router.route('/test') // Test connection + return basic infos about user.
//POST
.post(function(req,res){
connect.testConnect(req,res);
})
router.route('/notif') // Register to receive NEWS notifs
.post(function(req,res){
notif.register(req,res);
});
router.route('/notif/new') // Get unreded notifs
.post(function(req,res){
notif.getNew(req,res);
});
router.route('/notif/old') // Get readed notifs
.post(function(req,res){
notif.getOld(req,res);
});
router.route('/notif/remove') // Remove a notif
.post(function(req,res){
notif.remove(req,res);
});
router.route('/notif/send') // send a notif to all users (TEMPORAIRE)
.post(function(req,res){
//notif.sendAll(req,res);
});
router.route('/news')
//GET
.get(function(req,res){
news.get(req,res);
})
router.route('/news/:id')
//GET
.get(function(req,res){
news.one(req,res);
})
router.route('/news/:id/comments')
.get(function(req,res){
news.com(req,res);
})
.post(function(req,res){
news.sendcom(req,res);
})
router.route('/mp') // Return MP list
//POST
.post(function(req,res){
mp.getMp(req,res);
})
router.route('/mp/:id') // Return the MP with :id
//POST
.post(function(req,res){
mp.readMp(req,res);
})
router.route('/mp/send/:id') // Send a message to :id /!\ SITE ID, NOT FORUM ID /!\
// The function will recup some ids and lang informations from the site (hidden input), and after, send the mp with the given message.
//POST
.post(function(req,res){
mp.send(req,res);
})
router.route('/profile/:id') // Return profile :id
// GET
.get(function(req,res){
profile.getAsProfile(req,res, 'en', 'hub');
})
router.route('/profile/:lang/:sitename/:id') // Return profile :id
// GET
.get(function(req,res){
profile.getAsProfile(req,res, req.params.lang, req.params.sitename);
})
router.route('/profile/:id/comments') // GET : Return comments on profile :id, ?page // POST : Send ?comm comment on profile :id
// GET
.get(function(req,res){
profile.getCommentProfile(req,res);
})
.post(function(req,res){
profile.sendCommentProfile(req,res);
})
router.route('/profile/:lang/:sitename/:id/comments') // GET : Return comments on profile :id, ?page // POST : Send ?comm comment on profile :id
// GET
.get(function(req,res){
profile.getCommentProfile(req,res);
})
.post(function(req,res){
profile.sendCommentProfile(req,res);
})
router.route('/connect') // Return a PHPSESSID for futur use. A sort of API key lol. Param cookie is needed on all POST request.
// POST user/pass
.post(function(req,res){
connect.connect(req,res);
})
router.route('/chat/:lang/active') // Return actives chats
// GET
.get(function(req,res){
chat.getAsActiveChat(req,res);
})
router.route('/chat/:lang/:sitename/:chat') // GET : Return the chat :sitename, :chat can be : 'chat', 'chat_shared' or 'chat_rpg' (sorry mods, you can't access to the mod chat.)
// POST : Send ?message to the chat :sitename
// GET
.get(function(req,res){
chat.getAsChat(req, res);
})
//POST message/cookie
.post(function(req,res){
chat.sendAsChat(req,res);
});
router.route('/search/:lang/:sitename/:type/:subtype/:search') // Search :search on :sitename. :type can be '...'. :sybtype can be 'object' or 'author'.
// GET
.get(function(req,res){
search.search(req,res);
})
router.route('/fanart/:lang/:sitename/') // Get must_see and artist galleres (?page)
// GET
.get(function(req,res){ // req.query.page = The Page
fanart.main(req,res, 'art');
})
router.route('/fanimage/:lang/:sitename/')
// GET
.get(function(req,res){ // req.query.page = The Page
fanart.main(req,res, 'image');
})
router.route('/fanart/:lang/:sitename/:idartist/') // Get artist gallerie
// GET
.get(function(req,res){
fanart.artist(req,res, 'art');
})
router.route('/fanimage/:lang/:sitename/:idartist/')
// GET
.get(function(req,res){
fanart.artist(req,res, 'image');
})
router.route('/fanart/:lang/:sitename/:idartist/:id*?/comments') // Get comments
// GET
.get(function(req,res){
fanart.com(req,res, 'art');
})
.post(function(req,res){
fanart.sendcom(req,res, 'art');
})
router.route('/fanimage/:lang/:sitename/:idartist/:id*?/comments')
// GET
.get(function(req,res){
fanart.com(req,res, 'image');
})
.post(function(req,res){
fanart.sendcom(req,res, 'image');
})
router.route('/fanart/:lang/:sitename/:idartist/:id') // Get a fanart.
// GET
.get(function(req,res){
fanart.view(req,res, 'art');
})
router.route('/fanimage/:lang/:sitename/:idartist/:id')
// GET
.get(function(req,res){
fanart.view(req,res, 'image');
})
router.route('/fan:type/:lang/:sitename/') // Fanfic,musics,videos,game books.
// GET
.get(function(req,res){
fanfic.main(req,res, req.params.type);
})
router.route('/fan:type/:lang/:sitename/:idartist/')
// GET
.get(function(req,res){
fanfic.artist(req,res, req.params.type);
})
router.route('/fan:type/:lang/:sitename/:idartist/:id*?/comments')
// GET
.get(function(req,res) {
fanfic.com(req,res, req.params.type);
})
.post(function(req,res) {
fanfic.sendcom(req,res, req.params.type);
})
router.route('/chars/:lang/:sitename/')
// GET
.get(function(req,res) { // req.query.page = The Page
chars.main(req,res);
})
router.route('/chars/:lang/:sitename/:id')
// GET
.get(function(req,res) { // req.query.page = The Page
chars.view(req,res);
})
router.route('/chars/:lang/:sitename/:id/comments')
// GET
.get(function(req,res) { // req.query.page = The Page
chars.com(req,res);
})
.post(function(req,res) {
chars.sendcom(req,res);
})
router.route('/custom/')
// GET
.post(function(req,res) {
other.custom(req,res);
})
router.route('/sitemap/:lang/:sitename')
// GET
.get(function(req,res) {
other.sitemap(req,res);
})
app.use(router);
app.set('port', (process.env.PORT || 5000));
var test = app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});