-
What do you want to achieve? I am wondering how do you make urls like
www.example.com/site/123/456
and not likewww.example.site/site?key=123¬e=456
DON’T GO TO THE SITE AS IT’S JUST AN EXAMPLE
-
What is the issue? I have no idea how to do it, and it remained like this
www.example.com/GetDataStores?UniId=1500&ApiKey=l0rem¡psum&prefix=test&limit=50
-
What solutions have you tried so far? I searched up here but never ended up finding any
This is the code for the main script
const crypto = require("crypto")
const axios = require("axios")
const express = require("express")
const app = express();
app.use(express.static("public"));
app.get("/GetDataStores",async(req,res) =>{
let UniId = req.body("UniId")
let ApiKey = req.body("ApiKey")
let prefix = req.body("prefix")
let limit = req.body("limit")
const data = {
params:{
'prefix': prefix,
'limit': limit
},
headers: {
'x-api-key': ApiKey
}
}
await axios.get('https://apis.roblox.com/datastores/v1/universes/'+UniId+'/standard-datastores',data)
.then(function (response) {
console.log(response.data)
res.json([response.data])
})
.catch(function (error) {
// handle error
console.log(error.response.data);
})
.finally(function () {
// always executed
});
})
app.get("/GetEntry",async function(req,res){
let UniId = req.body("UniId")
let ApiKey = req.body("ApiKey")
let Name = req.body("name")
const data = {
params:{
'dataStoreName': 'scripts/'+Name,
'entryKey': '1'
},
headers: {
'x-api-key': ApiKey
}
}
await axios.get('https://apis.roblox.com/datastores/v1/universes/'+UniId+'/standard-datastores/datastore/entries/entry',data)
.then(function (response) {
console.log(response.data)
res.json([response.data])
})
.catch(function (error) {
// handle error
console.log(error.response.data);
})
.finally(function () {
// always executed
});
})
app.get("/GetEntries",async function(req,res){
const data = {
params:{
'dataStoreName': 'scripts/Jeff',
'prefix': '',
'limit': '2'
},
headers: {
'x-api-key': process.env.Api_KeyImportant1
}
}
await axios.get('https://apis.roblox.com/datastores/v1/universes/4442833374/standard-datastores/datastore/entries',data)
.then(function (response) {
console.log(response.data)
res.json([response.data])
})
.catch(function (error) {
// handle error
console.log(error.response.data);
})
.finally(function () {
// always executed
});
})
app.get("/SetEntry",async function(req,res){
let msg = req.param("msg")
let UniId = req.param("UniId")
let ApiKey = req.param("ApiKey")
let Name = req.param("name")
console.log(msg)
let stuff = JSON.stringify(msg)
console.log(stuff)
let idk = crypto.createHash("md5").update(stuff).digest("base64")
console.log(idk)
const data = {
params:{
'datastoreName': "scripts/"+Name,
'entryKey': '1'
},
headers: {
'x-api-key': ApiKey,
'content-md5': idk,
'content-type': 'application/json'
}
}
await axios.post('https://apis.roblox.com/datastores/v1/universes/'+UniId+'/standard-datastores/datastore/entries/entry',msg,data)
.then(function (response) {
console.log(response.data)
res.json([response.data])
})
.catch(function (error) {
// handle error
console.log(error.response.data);
})
.finally(function () {
// always executed
});
})
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
Here’s the package.json
{
"name": "nodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@types/node": "^18.0.6",
"axios": "^1.4.0",
"express": "^4.18.2",
"noblox.js": "^4.14.1",
"node-fetch": "^3.2.6"
}
}