-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (33 loc) · 827 Bytes
/
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
const express = require("express")
const fs = require("fs")
const parser = require("body-parser")
const app = express()
const enc = parser.urlencoded({extended: false})
app.use(express.static("public"))
app.get("/", (req, res) => {
res.send("Please update our apps, for you to make updated.")
})
app.post("/updates", enc, (req, res) => {
let data = req.body.package
if(data == undefined){
res.end("Something went wrong.")
}else{
let js_ = JSON.parse(fs.readFileSync("a.json", "utf8"))
let json = js_[data]
if(json != undefined){
let f = {
"version": json.ver,
"link": json.url,
"description": json.desc,
"isRequired": json.req
}
res.end(JSON.stringify(f))
}else{
res.end("Not found")
}
}
})
app.listen(3000, () => {
console.log("Listening to default port")
})
module.exports = app