mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-23 12:00:29 +03:00
Added /live endpoint.
This commit is contained in:
parent
36a1b2dd01
commit
b67f0db579
@ -30,22 +30,16 @@ var makeSlug = function(str) {
|
||||
}
|
||||
|
||||
var makeName = function(str) {
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)$/.exec(str);
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)(\/live)?$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3];
|
||||
}
|
||||
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/test$/.exec(str);
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/(test|beta)$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]";
|
||||
}
|
||||
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/beta$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [BETA]";
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [" + match[4].toUpperCase() + "]";
|
||||
}
|
||||
|
||||
return str;
|
||||
|
@ -121,22 +121,16 @@
|
||||
return finishedslug.toLowerCase();
|
||||
}
|
||||
var makeName = function(str) {
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)$/.exec(str);
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)(\/live)?$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3];
|
||||
}
|
||||
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/test$/.exec(str);
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/(test|beta)$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [TEST]";
|
||||
}
|
||||
|
||||
var match = /^https:\/\/eddn.edcd.io\/schemas\/(\w)(\w*)\/(\d+)\/beta$/.exec(str);
|
||||
if(match)
|
||||
{
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [BETA]";
|
||||
return match[1].toUpperCase() + match[2] + " v" + match[3] + " [" + match[4].toUpperCase() + "]";
|
||||
}
|
||||
|
||||
return str;
|
||||
|
@ -21,7 +21,7 @@ server {
|
||||
ssl_certificate /etc/letsencrypt/live/eddn.edcd.io/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/eddn.edcd.io/privkey.pem;
|
||||
|
||||
location ~ "^/schemas/(.*)/([\d]{1})(/(test|beta))?$" {
|
||||
location ~ "^/schemas/(.*)/([\d]{1})(/(test|beta|live))?$" {
|
||||
add_header Content-Type application/json;
|
||||
alias /home/EDDN/schemas/$1-v$2.0.json;
|
||||
}
|
||||
|
@ -202,10 +202,16 @@ class Monitor(Thread):
|
||||
c.execute('INSERT IGNORE INTO `softwares` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (softwareID, ))
|
||||
db.commit()
|
||||
|
||||
# remove live endpoint from schema for the update
|
||||
if schemaID.endswith('/live'):
|
||||
upd_schema = schemaID[:-5]
|
||||
else:
|
||||
upd_schema = schemaID
|
||||
|
||||
# Update schemas count
|
||||
c = db.cursor()
|
||||
c.execute('UPDATE `schemas` SET `hits` = `hits` + 1 WHERE `name` = %s AND `dateStats` = UTC_DATE()', (schemaID, ))
|
||||
c.execute('INSERT IGNORE INTO `schemas` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (schemaID, ))
|
||||
c.execute('UPDATE `schemas` SET `hits` = `hits` + 1 WHERE `name` = %s AND `dateStats` = UTC_DATE()', (upd_schema, ))
|
||||
c.execute('INSERT IGNORE INTO `schemas` (`name`, `dateStats`) VALUES (%s, UTC_DATE())', (upd_schema, ))
|
||||
db.commit()
|
||||
|
||||
db.close()
|
||||
|
@ -46,22 +46,27 @@ class _Settings(object):
|
||||
|
||||
GATEWAY_JSON_SCHEMAS = {
|
||||
"https://eddn.edcd.io/schemas/commodity/3" : "schemas/commodity-v3.0.json",
|
||||
"https://eddn.edcd.io/schemas/commodity/3/live" : "schemas/commodity-v3.0.json",
|
||||
"https://eddn.edcd.io/schemas/commodity/3/test" : "schemas/commodity-v3.0.json",
|
||||
"https://eddn.edcd.io/schemas/commodity/3/beta" : "schemas/commodity-v3.0.json",
|
||||
|
||||
"https://eddn.edcd.io/schemas/shipyard/2" : "schemas/shipyard-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/shipyard/2/live" : "schemas/shipyard-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/shipyard/2/test" : "schemas/shipyard-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/shipyard/2/beta" : "schemas/shipyard-v2.0.json",
|
||||
|
||||
"https://eddn.edcd.io/schemas/outfitting/2" : "schemas/outfitting-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/outfitting/2/live" : "schemas/outfitting-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/outfitting/2/test" : "schemas/outfitting-v2.0.json",
|
||||
"https://eddn.edcd.io/schemas/outfitting/2/beta" : "schemas/outfitting-v2.0.json",
|
||||
|
||||
"https://eddn.edcd.io/schemas/blackmarket/1" : "schemas/blackmarket-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/blackmarket/1/live" : "schemas/blackmarket-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/blackmarket/1/test" : "schemas/blackmarket-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/blackmarket/1/beta" : "schemas/blackmarket-v1.0.json",
|
||||
|
||||
"https://eddn.edcd.io/schemas/journal/1" : "schemas/journal-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/journal/1/live" : "schemas/journal-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/journal/1/test" : "schemas/journal-v1.0.json",
|
||||
"https://eddn.edcd.io/schemas/journal/1/beta" : "schemas/journal-v1.0.json",
|
||||
}
|
||||
|
@ -36,9 +36,15 @@ class DuplicateMessages(Thread):
|
||||
if re.search('test', json['$schemaRef'], re.I):
|
||||
return False
|
||||
|
||||
# remove live endpoint from schema
|
||||
if json['$schemaRef'].endswith('/live'):
|
||||
schema_ref = json['$schemaRef'][:-5]
|
||||
else:
|
||||
schema_ref = json['$schemaRef']
|
||||
|
||||
# Shallow copy, minus headers
|
||||
jsonTest = {
|
||||
'$schemaRef': json['$schemaRef'],
|
||||
'$schemaRef': schema_ref,
|
||||
'message': dict(json['message']),
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user