Skip to content

Commit

Permalink
fixed md, added sxcu files
Browse files Browse the repository at this point in the history
  • Loading branch information
TannerReynolds committed Mar 10, 2019
1 parent faa4893 commit bc515ac
Show file tree
Hide file tree
Showing 59 changed files with 138 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
server/uploads/* linguist-vendored
src/server/uploads/* linguist-vendored
.github/* linguist-vendored
server/views/* linguist-vendored
src/server/views/* linguist-vendored
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/node_modules
config.real.json
package-lock.json
src/node_modules
src/config.real.json
src/package-lock.json
12 changes: 12 additions & 0 deletions Images_and_Files.sxcu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": "12.4.0",
"Name": "Images_and_Files",
"DestinationType": "ImageUploader, FileUploader",
"RequestMethod": "POST",
"RequestURL": "http://[YOUR_DOMAIN]/api/files",
"Body": "MultipartFormData",
"Arguments": {
"key": "YOUR_PASSWORD"
},
"FileFormName": "fdata"
}
12 changes: 12 additions & 0 deletions Text.sxcu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": "12.4.0",
"Name": "Text",
"DestinationType": "TextUploader",
"RequestMethod": "POST",
"RequestURL": "http://[YOUR_DOMAIN]/api/paste",
"Body": "MultipartFormData",
"Arguments": {
"key": "YOUR_PASSWORD"
},
"FileFormName": "fdata"
}
15 changes: 15 additions & 0 deletions URL_Shortener.sxcu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Version": "12.4.0",
"Name": "URL_Shortener",
"DestinationType": "URLShortener",
"RequestMethod": "POST",
"RequestURL": "http://[YOUR_DOMAIN]/api/shortener",
"Headers": {
"url": "$input$"
},
"Body": "MultipartFormData",
"Arguments": {
"key": "YOUR_PASSWORD"
},
"FileFormName": "fdata"
}
64 changes: 0 additions & 64 deletions server/routes/paste.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 26 additions & 29 deletions config.json → src/config.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
{
"key": "",
"public": false,
"maxUploadSize": 50,
"markdown": true,
"port": 80,
"secure": true,
"securePort": 443,
"ratelimit": 1000,
"allowed":[
"png", "jpg", "gif", "mp4", "mp3", "jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv"
],
"admin":{
"key": "admin pass key goes here",
"maxUploadSize": 1024,
"allowed": [
"png", "jpg", "gif", "mp4", "mp3","jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv", "html"
]
},
"paste": {
"maxUploadSize": 20,
"allowed": [
"js", "php", "html", "txt", "lua", "json", "yml", "go", "cr", "bat", "css", "cs", "java", "py", "less", "c", "cpp", "ini", "pl", "sql", "rb", "md"
]
},
"discordToken": "Discord Token Here (required if you want API monitoring through Discord)",
"discordAdminIDs": ["discord IDs of people who can run commands go here", "Like this"],
"discordChannelID": "the channel you're trying to send api monitor updates to",
"prefix": "enter prefix for bot commands here"
{
"key": "",
"public": false,
"maxUploadSize": 50,
"markdown": true,
"port": 80,
"secure": true,
"securePort": 443,
"ratelimit": 1000,
"allowed":[
"png", "jpg", "gif", "mp4", "mp3", "jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv"
],
"admin":{
"key": "admin pass key goes here",
"maxUploadSize": 1024,
"allowed": [
"png", "jpg", "gif", "mp4", "mp3","jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv", "html"
]
},
"paste": {
"maxUploadSize": 20
},
"discordToken": "Discord Token Here (required if you want API monitoring through Discord)",
"discordAdminIDs": ["discord IDs of people who can run commands go here", "Like this"],
"discordChannelID": "the channel you're trying to send api monitor updates to",
"prefix": "enter prefix for bot commands here"
}
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if which node > /dev/null
then
echo "\x1b[32mNode is already installed, skipping...\x1b[0m"
else
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
npm i
2 changes: 1 addition & 1 deletion package.json → src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sharexapi",
"version": "3.5.0",
"version": "4.0.0",
"description": "ShareX API made in Nodejs. Includes images, videos, code, text, and url shortening",
"dependencies": {
"body-parser": "^1.18.3",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion server/routes/files.js → src/server/routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require("fs-extra")
const Remarkable = require("remarkable")
const ejs = require("ejs")
const md = new Remarkable("full", {
html: true,
html: false,
linkify: true,
typographer: true
})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions src/server/routes/paste.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const path = require("path")
const formidable = require("formidable")
const fs = require("fs-extra")
const ejs = require("ejs")
async function paste(req, res) {
res.setHeader("Content-Type", "text/text")
let fileName = this.randomToken(5) // 916,132,832 possible file names
let form = new formidable.IncomingForm()
form.parse(req, (err, fields, files) => {
let userIP = req.headers["x-forwarded-for"] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress
if (!this.auth(this.c.key, fields.key, this.c)) {
res.statusCode = 401
res.write("Unauthorized");
res.end();
return this.log.warning(`Unauthorized User | File Upload | ${userIP}`)
}
this.db.get("files")
.push({
path: `/${fileName}`,
ip: userIP,
views: 0
})
.write();
let oldpath = files.fdata.path
let newpath = `${__dirname}/../uploads/${fileName+files.fdata.name.toString().match(/(\.)+([a-zA-Z0-9]+)+/g, "").toString()}`;
if (Math.round((files.fdata.size / 1024) / 1000) > this.c.paste.max_upload_size) {
if (this.monitorChannel !== null) this.bot.createMessage(this.monitorChannel, `\`\`\`MARKDOWN\n[FAILED PASTE][USER]\n[FILE](${files.fdata.name})\n[SIZE](${Math.round(files.fdata.size/1024)}KB)\n[TYPE](${files.fdata.type})\n[IP](${userIP})\n\n[ERROR](ERR_FILE_TOO_BIG)\`\`\``)
res.statusCode = 413
res.write(`http://${req.headers.host}/ERR_FILE_TOO_BIG`)
return res.end()
} else {
fs.move(oldpath, newpath, err => {
fs.readFile(newpath, "utf-8", function read(err, data) {
let stream = fs.createWriteStream(`${__dirname}/../uploads/${fileName}.html`)
stream.once("open", fd => {
let cleaned = data.replace(/>/g, "&gt")
cleaned = cleaned.replace(/</g, "&lt")
ejs.renderFile(`${__dirname}/../views/paste.ejs`, {
ogDesc: data.match(/.{1,297}/g)[0],
pData: data
}, {}, (err, str) => {
stream.write(str)
})
stream.end()
fs.unlink(newpath, err => {
if (err) return
});
let insecure = `http://${req.headers.host}/${fileName}`
let secure = `https://${req.headers.host}/${fileName}`
res.write(req.secure ? secure : insecure)
return res.end()
})
})
})
}
})
}
module.exports = paste
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bc515ac

Please sign in to comment.