-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (37 loc) · 1.18 KB
/
Copy pathindex.js
File metadata and controls
43 lines (37 loc) · 1.18 KB
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
global.express = require('express');
global.app = express();
global.bodyParser = require('body-parser');
global.sorgu = require('./sorgu.js').sorgu;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
///////////////////////// GET - POST /////////////////////////
app.get('/api', async (req, res) => {
let username = req.query.username;
if (!username) return res.send({
error: true,
message: 'Lütfen bir kullanıcı adı giriniz.'
});
if (username.length < 3) return res.send({
error: true,
message: 'Lütfen geçerli bir kullanıcı adı giriniz.'
});
let check = await sorgu(username);
if (!check.status) return res.send({
error: true,
message: 'Bir hata oluştu. Lütfen daha sonra tekrar deneyiniz.'
});
res.json(check);
});
app.use((req, res, next) => {
res.status(404).send({
error: true,
message: '404: Sayfa bulunamadı.',
github: 'github.com/fastuptime'
});
});
///////////////////////// GET - POST /////////////////////////
app.listen(80, () => {
console.log('Web site açıldı. Port: 80')
});