move all api options to their own file
This commit is contained in:
parent
4d3e22ebfa
commit
9557dd89b1
38
routes/api/options.js
Normal file
38
routes/api/options.js
Normal file
@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
"setup": function(router,con,server) {
|
||||
router.options("/api/pid",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/post",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","POST")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getotheruser",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getPost",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getPostsLowerThan",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
}
|
||||
}
|
40
server.js
40
server.js
@ -400,41 +400,6 @@ START /API/*
|
||||
|
||||
*/
|
||||
|
||||
router.options("/api/pid",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/post",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","POST")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getotheruser",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getPost",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
router.options("/api/getPostsLowerThan",async function(req,res,next) {
|
||||
res.set("Access-Control-Allow-Origin","*") //we'll allow it for now
|
||||
res.set("Access-Control-Allow-Methods","GET")
|
||||
res.set("Access-Control-Allow-Headers","Content-Type")
|
||||
res.status(200).send("")
|
||||
})
|
||||
|
||||
const commonfunctions = {
|
||||
increaseAPICall,
|
||||
increaseUSERCall,
|
||||
@ -442,9 +407,14 @@ const commonfunctions = {
|
||||
increaseIndividualCall
|
||||
}
|
||||
|
||||
let options = require("./routes/api/options.js")
|
||||
options.setup(router,con,commonfunctions)
|
||||
|
||||
let apiALL = require("./routes/api/all.js")
|
||||
apiALL.setup(router,con,commonfunctions)
|
||||
|
||||
//TODO: loop through all files and load them in
|
||||
|
||||
router.get("/api/search", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","")
|
||||
let type = req.query.type
|
||||
|
Loading…
x
Reference in New Issue
Block a user