mirror of
https://github.com/Open-Argon/isotope-server.git
synced 2026-10-28 09:43:51 +00:00
make store files
This commit is contained in:
1 parent
926bb9844a
commit
fd94dd6e61
14 files changed
+148
-147
No files matched your search
@@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
+8
-124
@@ -1,127 +1,11 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
.DS_Store
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
# isotope
|
||||
__isotope__
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
# argon
|
||||
argon_modules
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
# main
|
||||
packages
|
||||
packages-db.json
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.ar": "lua"
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 William Bell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,13 @@
|
||||
import "server" as *
|
||||
import "config" as *
|
||||
import "save"
|
||||
|
||||
# routes
|
||||
|
||||
|
||||
# isotope
|
||||
import "routes/isotope/push" as *
|
||||
import "routes/isotope/search" as *
|
||||
import "routes/isotope/download" as *
|
||||
|
||||
app.run()
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "isotope-server",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[{"Name":"http.ar","Version":"1.0.0","URL":"http://localhost:7030/isotope-download?version=latest\u0026name=http.ar"}]
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
let randstr(length) = do
|
||||
let chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
let id = ""
|
||||
for (i from 0 to length) do
|
||||
id = id + chars[random.int(0, chars.length-1)]
|
||||
return id
|
||||
@@ -0,0 +1,23 @@
|
||||
import "../server" as *
|
||||
import "../config" as *
|
||||
import "../save" as *
|
||||
|
||||
let search(req, res) = do
|
||||
let name = req.query.name
|
||||
let version = req.query.version
|
||||
let package = packages.get(name)
|
||||
if (package == null) do
|
||||
res.code = 404
|
||||
res.send("Package not found")
|
||||
return
|
||||
let currentVersion = package.versions.get(version)
|
||||
forever do
|
||||
let redirect = currentVersion.get("redirect")
|
||||
if (redirect) do
|
||||
currentVersion = package.versions.get(redirect)
|
||||
continue
|
||||
break
|
||||
let filename = currentVersion.get("filename")
|
||||
let p = path.join([program.cwd,"packages", name, filename])
|
||||
res.sendFile(p)
|
||||
app.route("/isotope-download", null, search)
|
||||
@@ -0,0 +1,27 @@
|
||||
import "../server" as *
|
||||
import "../randstr" as *
|
||||
import "../save" as *
|
||||
|
||||
let push(req, res) = do
|
||||
let name = req.formdata.name
|
||||
let version = req.formdata.version
|
||||
let file = req.files.file
|
||||
let package = packages.get(name)
|
||||
if (package == null) do
|
||||
package = {versions:{}}
|
||||
packages[name] = package
|
||||
let currentVersion = package.versions.get(version)
|
||||
let directory = path.join([program.cwd, "packages", name])
|
||||
if (currentVersion == null) do
|
||||
currentVersion = {name:name, version:version}
|
||||
package.versions[version] = currentVersion
|
||||
let filename = version+".tar.gz"
|
||||
let p = path.join([directory, filename])
|
||||
term.log(directory)
|
||||
path.mkAllDir(directory)
|
||||
file.save(p)
|
||||
currentVersion.filename = filename
|
||||
package.versions['latest'] = {redirect: version}
|
||||
changes.n = changes.n + 1
|
||||
res.send("OK")
|
||||
app.route("/isotope-push", ['POST'], push)
|
||||
@@ -0,0 +1,24 @@
|
||||
import "../server" as *
|
||||
import "../config" as config
|
||||
import "../save" as *
|
||||
import "http.ar/url" as urllib
|
||||
|
||||
let search(req, res) = do
|
||||
let name = req.query.name
|
||||
let version = req.query.version
|
||||
let package = packages.get(name)
|
||||
if (package == null) do
|
||||
res.code = 404
|
||||
res.send("Package not found")
|
||||
return
|
||||
let currentVersion = package.versions.get(version)
|
||||
forever do
|
||||
let redirect = currentVersion.get("redirect")
|
||||
if (redirect) do
|
||||
currentVersion = package.versions.get(redirect)
|
||||
continue
|
||||
break
|
||||
let filename = currentVersion.get("filename")
|
||||
let URL = config.url+"/isotope-download?"+urllib.queryStr({name:currentVersion.name, version:currentVersion.version})
|
||||
res.json({Name: currentVersion.name, Version: currentVersion.version, URL:URL })
|
||||
app.route("/isotope-search", null, search)
|
||||
@@ -0,0 +1,28 @@
|
||||
let packages = {}
|
||||
let savePath = path.join([program.cwd, "packages-db.json"])
|
||||
|
||||
let changes = {n: 0, last: 0}
|
||||
|
||||
let load() = do
|
||||
if (path.exists(savePath)) do
|
||||
let file = file.read(savePath)
|
||||
packages = file.json()
|
||||
file.close()
|
||||
|
||||
let save() = do
|
||||
if (changes.n == changes.last) return
|
||||
let file = file.write(savePath)
|
||||
file.json(packages)
|
||||
file.close()
|
||||
|
||||
let saveThread() = do
|
||||
while (true) do
|
||||
try do
|
||||
save()
|
||||
catch (e) do
|
||||
term.log(e)
|
||||
time.snooze(10)
|
||||
|
||||
load()
|
||||
t = thread(saveThread)
|
||||
t.start()
|
||||
Reference in new issue
Block a user